Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define NULL 0
- #define HOLDING(%0) ((newkeys & (%0)) == (%0))
- #define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- #define RELEASED(%0) (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
- #define SCM(%0) SendClientMessage(playerid, -1, %0)
- new TIMER__[128];
- new PASFPEX__TIMER__VAR[MAX_PLAYERS];
- stock PlayAudioStreamForPlayerEx(playerid, url[], duration = NULL) {
- if(duration == NULL || duration == -1) {
- KillTimer(PASFPEX__TIMER__VAR[playerid]);
- StopAudioStreamForPlayer(playerid);
- } else if(duration != NULL) {
- format(TIMER__, sizeof(TIMER__), url);
- PASFPEX__TIMER__VAR[playerid] = SetTimerEx("PASFPEX__TIMER", duration, true, "ds", playerid, TIMER__);
- PlayAudioStreamForPlayer(playerid, url);
- }
- }
- forward PASFPEX__TIMER(playerid, url[], duration);
- public PASFPEX__TIMER(playerid, url[], duration) {
- StopAudioStreamForPlayer(playerid);
- PlayAudioStreamForPlayer(playerid, TIMER__);
- }
- public OnPlayerCommandText(playerid, cmdtext[]) {
- if(strcmp(cmdtext, "/sound",true) == 0) {
- PlayAudioStreamForPlayerEx(playerid, "http://www.cms.livjm.ac.uk/library/Alice/Alice/Required/sounds/chicken.mp3", -1);
- return 1;
- }
- return false;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate) {
- if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
- StopAudioStreamForPlayer(playerid);
- }
- return true;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
- if(!IsPlayerInAnyVehicle(playerid)) return StopAudioStreamForPlayer(playerid), KillTimer(PASFPEX__TIMER__VAR[playerid]);
- else {
- if(PRESSED(KEY_CROUCH) && HOLDING(KEY_CROUCH)) {
- // PlayAudioStreamForPlayerEx(playerid, "http://alldev.eu/html/mp3/sound_011.wav", 3766);
- // SCM("Test");
- // StopAudio(playerid);
- PlayAudioStreamForPlayerEx(playerid, "http://alldev.eu/html/mp3/sound_012.wav", 286);
- SCM("Test2");
- } else if(RELEASED(KEY_CROUCH)) {
- SCM("Test3");
- StopAudioStreamForPlayer(playerid);
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement