Advertisement
Shiny_

wtf_ex

Feb 16th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.99 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define NULL 0
  4. #define HOLDING(%0) ((newkeys & (%0)) == (%0))
  5. #define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  6. #define RELEASED(%0) (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
  7.  
  8. #define SCM(%0) SendClientMessage(playerid, -1, %0)
  9.  
  10. new TIMER__[128];
  11. new PASFPEX__TIMER__VAR[MAX_PLAYERS];
  12. stock PlayAudioStreamForPlayerEx(playerid, url[], duration = NULL) {
  13.     if(duration == NULL || duration == -1) {
  14.         KillTimer(PASFPEX__TIMER__VAR[playerid]);
  15.         StopAudioStreamForPlayer(playerid);
  16.     } else if(duration != NULL) {
  17.         format(TIMER__, sizeof(TIMER__), url);
  18.         PASFPEX__TIMER__VAR[playerid] = SetTimerEx("PASFPEX__TIMER", duration, true, "ds", playerid, TIMER__);
  19.         PlayAudioStreamForPlayer(playerid, url);
  20.     }
  21. }
  22.  
  23. forward PASFPEX__TIMER(playerid, url[], duration);
  24. public PASFPEX__TIMER(playerid, url[], duration) {
  25.     StopAudioStreamForPlayer(playerid);
  26.     PlayAudioStreamForPlayer(playerid, TIMER__);
  27. }
  28.  
  29. public OnPlayerCommandText(playerid, cmdtext[]) {
  30.     if(strcmp(cmdtext, "/sound",true) == 0) {
  31.         PlayAudioStreamForPlayerEx(playerid, "http://www.cms.livjm.ac.uk/library/Alice/Alice/Required/sounds/chicken.mp3", -1);
  32.         return 1;
  33.     }
  34.     return false;
  35. }
  36.  
  37. public OnPlayerStateChange(playerid, newstate, oldstate) {
  38.     if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
  39.         StopAudioStreamForPlayer(playerid);
  40.     }
  41.     return true;
  42. }
  43.  
  44. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
  45.     if(!IsPlayerInAnyVehicle(playerid)) return StopAudioStreamForPlayer(playerid), KillTimer(PASFPEX__TIMER__VAR[playerid]);
  46.     else {
  47.         if(PRESSED(KEY_CROUCH) && HOLDING(KEY_CROUCH)) {
  48.             // PlayAudioStreamForPlayerEx(playerid, "http://alldev.eu/html/mp3/sound_011.wav", 3766);
  49.             // SCM("Test");
  50.             // StopAudio(playerid);
  51.             PlayAudioStreamForPlayerEx(playerid, "http://alldev.eu/html/mp3/sound_012.wav", 286);
  52.             SCM("Test2");
  53.         } else if(RELEASED(KEY_CROUCH)) {
  54.             SCM("Test3");
  55.             StopAudioStreamForPlayer(playerid);
  56.         }
  57.     }
  58.     return true;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement