Advertisement
Shiny_

wtf

Feb 16th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.37 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. public OnPlayerConnect(playerid) {
  9.     SetPVarInt(playerid, "duration", NULL);
  10.     SetPVarString(playerid, "url", "");
  11.     SetPVarFloat(playerid, "posX", 0.0);
  12.     SetPVarFloat(playerid, "posY", 0.0);
  13.     SetPVarFloat(playerid, "posZ", 0.0);
  14.     SetPVarFloat(playerid, "distance", 50.0);
  15.     SetPVarInt(playerid, "usepos", NULL);
  16.     return 1;
  17. }
  18.  
  19. #if defined _ALS_OnPlayerConnect
  20.     #undef OnPlayerConnect
  21. #else
  22.     #define _ALS_OnPlayerConnect
  23. #endif
  24.  
  25. #define OnPlayerConnect AudioMS_OnPlayerConnect
  26. forward AudioMS_OnPlayerConnect(playerid);
  27.  
  28. stock StopAudioStreamForPlayerEx(playerid) {
  29.     SetPVarInt(playerid, "duration", NULL);
  30.     SetPVarString(playerid, "url", "");
  31.     SetPVarFloat(playerid, "posX", 0.0);
  32.     SetPVarFloat(playerid, "posY", 0.0);
  33.     SetPVarFloat(playerid, "posZ", 0.0);
  34.     SetPVarFloat(playerid, "distance", 50.0);
  35.     SetPVarInt(playerid, "usepos", NULL);
  36.     StopAudioStreamForPlayer(playerid);
  37. }
  38.  
  39. stock PlayAudioStreamForPlayerEx(playerid, url[], duration, Float:posX = 0.0, Float:posY = 0.0, Float:posZ = 0.0, Float:distance = 50.0, usepos = NULL) {
  40.     if(GetPVarInt(playerid, "duration") == NULL) {
  41.         PlayAudioStreamForPlayer(playerid, url, posX, posY, posZ, distance, usepos);
  42.         SetPVarInt(playerid, "duration", duration);
  43.         SetPVarString(playerid, "url", url);
  44.         SetPVarFloat(playerid, "posX", posX);
  45.         SetPVarFloat(playerid, "posY", posY);
  46.         SetPVarFloat(playerid, "posZ", posZ);
  47.         SetPVarFloat(playerid, "distance", distance);
  48.         SetPVarInt(playerid, "usepos", usepos);
  49.         if(duration != -1) {
  50.             SetTimerEx("StopAudio", duration, NULL, "d", playerid);
  51.         }
  52.     } else if(GetPVarInt(playerid, "duration") == -1) {
  53.         StopAudioStreamForPlayer(playerid);
  54.         PlayAudioStreamForPlayer(playerid, url, posX, posY, posZ, distance, usepos);
  55.         if(duration != -1) {
  56.             new URL[128];
  57.             GetPVarString(playerid, "url", URL, sizeof(URL));
  58.             SetTimerEx("SetNextStream", duration, NULL, "dsdffffd", playerid, URL, GetPVarInt(playerid, "duration"), GetPVarFloat(playerid, "posX"), GetPVarFloat(playerid, "posY"), GetPVarFloat(playerid, "posZ"), GetPVarFloat(playerid, "distance"), GetPVarInt(playerid, "usepos"));
  59.         }
  60.     } else {
  61.         StopAudioStreamForPlayer(playerid);
  62.         PlayAudioStreamForPlayer(playerid, url, posX, posY, posZ, distance, usepos);
  63.  
  64.         if(duration != -1) {
  65.             new URL[128];
  66.             GetPVarString(playerid, "url", URL, sizeof(URL));
  67.             SetTimerEx("SetNextStream", duration, NULL, "dsdffffd", playerid, URL, GetPVarInt(playerid, "duration"), GetPVarFloat(playerid, "posX"), GetPVarFloat(playerid, "posY"), GetPVarFloat(playerid, "posZ"), GetPVarFloat(playerid, "distance"), GetPVarInt(playerid, "usepos"));
  68.         }
  69.     }
  70. }
  71.  
  72. forward StopAudio(playerid);
  73. public StopAudio(playerid) {
  74.     StopAudioStreamForPlayerEx(playerid);
  75. }
  76.  
  77. forward SetNextStream(playerid, url[], duration, Float:posX, Float:posY, Float:posZ, Float:distance, usepos);
  78. public SetNextStream(playerid, url[], duration, Float:posX, Float:posY, Float:posZ, Float:distance, usepos) {
  79.     StopAudioStreamForPlayer(playerid);
  80.     new URL[128];
  81.     format(URL, sizeof(URL), url);
  82.     PlayAudioStreamForPlayer(playerid, URL, Float:posX, Float:posY, Float:posZ, Float:distance, usepos);
  83.    
  84.     SetPVarInt(playerid, "duration", duration);
  85.     SetPVarString(playerid, "url", URL);
  86.     SetPVarFloat(playerid, "posX", posX);
  87.     SetPVarFloat(playerid, "posY", posY);
  88.     SetPVarFloat(playerid, "posZ", posZ);
  89.     SetPVarFloat(playerid, "distance", distance);
  90.     SetPVarInt(playerid, "usepos", usepos);
  91.     if(duration != -1) {
  92.        SetTimerEx("StopAudio", duration, 0, "d", playerid);
  93.     }
  94.     return true;
  95. }
  96.  
  97. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
  98.     if(IsPlayerInAnyVehicle(playerid)) {
  99.         if(PRESSED(KEY_CROUCH)) {
  100.             PlayAudioStreamForPlayerEx(playerid, "http://alldev.eu/html/mp3/sound_011.wav", 3766);
  101.             StopAudio(playerid);
  102.         } else if(HOLDING(KEY_CROUCH)) {
  103.             PlayAudioStreamForPlayerEx(playerid, "http://alldev.eu/html/mp3/sound_012.wav", 286);
  104.         } else if(RELEASED(KEY_CROUCH)) {
  105.             StopAudio(playerid);
  106.         }
  107.     } else StopAudio(playerid);
  108.     return true;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement