Advertisement
Guest User

Soumi -- boombox filterscript

a guest
Aug 3rd, 2012
1,517
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.91 KB | None | 0 0
  1. /*
  2. Boombox filterscript created by Soumi.
  3. Copyright Soumi 2012.
  4. Commands:
  5. - /boombox : It will open a dialog where you can choose a radio station to play. After choosing the radio station,
  6. it will create a boombox object and starts playing the radio station for the players in range of 20.0.
  7. - /radiostation : To switch to another radio station.
  8. - /turnoff : To turn off the boombox.
  9.  
  10. P.S : - If a player leaves the boombox range, the audio stream will stop for him.
  11.       - If a player enters the boombox range, the audio stream will start playing for him.
  12. */
  13.  
  14. #define filterscript
  15. #include <a_samp>
  16. #include <zcmd>
  17. #include <sscanf2>
  18. #include <streamer>
  19.  
  20. // Colors defines
  21.  
  22. #define GREY            0xCECECEFF
  23. #define WHITE           0xFFFFFFFF
  24. #define RED             0xAA3333AA
  25. #define GOLD            0xB8860BAA
  26. #define ACTION_COLOR    0xC2A2DAAA
  27. #define GREEN           0x33AA33AA
  28. #define ORANGE          0xFF9900AA
  29. #define GUARDS_RADIO    0x33CCFFAA
  30. #define DOCTORS_RADIO   0xFFC0CBAA
  31. #define YELLOW          0xFFFF00AA
  32. #define BRONZE          0x800000AA
  33. #define SILVER          0xF5F5F5FF
  34.  
  35. // Player Stats
  36.  
  37. enum PlayerInfo
  38. {
  39.      BoomBoxObject,
  40.      Float: BoomBoxObjectX,
  41.      Float: BoomBoxObjectY,
  42.      Float: BoomBoxObjectZ,
  43.      BoomBoxStatus,
  44.      BoomBoxLink[512],
  45.      ListeningToBoomBox,
  46.  
  47. }
  48. new PlayerStat[MAX_PLAYERS][PlayerInfo];
  49.  
  50. forward OneSecondPlayerCheck(playerid);
  51.  
  52. #if defined FILTERSCRIPT
  53.  
  54. public OnFilterScriptInit()
  55. {
  56.     print("\n--------------------------------------");
  57.     print(" Boombox filterscript by Soumi ");
  58.     print("--------------------------------------\n");
  59.     LoadGangs();
  60.     return 1;
  61. }
  62.  
  63. public OnFilterScriptExit()
  64. {
  65.     return 1;
  66. }
  67.  
  68. #else
  69.  
  70. main()
  71. {
  72.     print("\n--------------------------------------");
  73.     print(" Boombox filterscript by Soumi ");
  74.     print("--------------------------------------\n");
  75. }
  76.  
  77. #endif
  78.  
  79. public OnPlayerConnect(playerid)
  80. {
  81.     PlayerStat[playerid][BoomBoxStatus] = -1;
  82.     PlayerStat[playerid][ListeningToBoomBox] = -1;
  83.     SetTimerEx("OneSecondPlayerCheck", 1000, true, "d", playerid);
  84.     return 1;
  85. }
  86.  
  87. public OnPlayerDisconnect(playerid, reason)
  88. {
  89.     if(PlayerStat[playerid][BoomBoxStatus] == playerid)
  90.     {
  91.         DestroyDynamicObject(PlayerStat[playerid][BoomBoxObject]);
  92.         for(new i = 0; i < MAX_PLAYERS; i++)
  93.         {
  94.             if(IsPlayerInRangeOfPoint(i, 20.0, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]))
  95.             {
  96.                 StopAudioStreamForPlayer(i);
  97.                 PlayerStat[i][ListeningToBoomBox] = 0;
  98.             }
  99.          }
  100.     }
  101.     return 1;
  102. }
  103.  
  104. public OneSecondPlayerCheck(playerid)
  105. {
  106.     for(new i = 0; i < MAX_PLAYERS; i++)
  107.     {
  108.         if(PlayerStat[i][BoomBoxStatus] == i && PlayerStat[playerid][ListeningToBoomBox] == -1)
  109.         {
  110.             if(IsPlayerInRangeOfPoint(i, 20.0, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]))
  111.             {
  112.                 PlayAudioStreamForPlayer(playerid, PlayerStat[i][BoomBoxLink], PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ], 10.0, 1);
  113.                 PlayerStat[playerid][ListeningToBoomBox] = i;
  114.             }
  115.         }
  116.         if(PlayerStat[i][BoomBoxStatus] == i && PlayerStat[playerid][ListeningToBoomBox] == i)
  117.         {
  118.             if(!IsPlayerInRangeOfPoint(i, 20.0, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]))
  119.             {
  120.                 StopAudioStreamForPlayer(playerid);
  121.                 PlayerStat[playerid][ListeningToBoomBox] = -1;
  122.             }
  123.         }
  124.     }
  125.     return 1;
  126. }
  127.  
  128. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  129. {
  130.     if(dialogid == 8888)
  131.     {
  132.         if(!response) return 1;
  133.         else if(response)
  134.         {
  135.             switch(listitem)
  136.             {
  137.                 case 0:
  138.                 {
  139.                     if(PlayerStat[playerid][BoomBoxStatus] != playerid)
  140.                     {
  141.                         GetPlayerPos(playerid, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]);
  142.                         PlayerStat[playerid][BoomBoxObject] = CreateDynamicObject(2103 ,PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ] -1,0.0000000,0.00000000,0.00000000);
  143.                         PlayerStat[playerid][BoomBoxStatus] = playerid;
  144.                         format(PlayerStat[playerid][BoomBoxLink], 512, "http://somafm.com/tags.pls");
  145.                         SendClientMessage(playerid, GREEN, "Boombox turned [ON].");
  146.                         SendClientMessage(playerid, WHITE, "Use /radiostation to switch to another radio station!");
  147.                     }
  148.                     else if(PlayerStat[playerid][BoomBoxStatus] == playerid)
  149.                     {
  150.                         format(PlayerStat[playerid][BoomBoxLink], 512, "http://somafm.com/tags.pls");
  151.                         SendClientMessage(playerid, GREEN, "Radio station changed.");
  152.                         for(new i = 0; i < MAX_PLAYERS; i++)
  153.                         {
  154.                             if(IsPlayerInRangeOfPoint(i, 20.0, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]))
  155.                             {
  156.                                 PlayAudioStreamForPlayer(i, PlayerStat[i][BoomBoxLink], PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ], 10.0, 1);
  157.                             }
  158.                         }
  159.                     }
  160.                 }
  161.                 case 1:
  162.                 {
  163.                     if(PlayerStat[playerid][BoomBoxStatus] != playerid)
  164.                     {
  165.                         GetPlayerPos(playerid, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]);
  166.                         PlayerStat[playerid][BoomBoxObject] = CreateDynamicObject(2103 ,PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ] -1,0.0000000,0.00000000,0.00000000);
  167.                         PlayerStat[playerid][BoomBoxStatus] = playerid;
  168.                         format(PlayerStat[playerid][BoomBoxLink], 512, "http://www.sky.fm/mp3/tophits.pls");
  169.                         SendClientMessage(playerid, GREEN, "Boombox turned [ON].");
  170.                         SendClientMessage(playerid, WHITE, "Use /radiostation to switch to another radio station!");
  171.                     }
  172.                     else if(PlayerStat[playerid][BoomBoxStatus] == playerid)
  173.                     {
  174.                         format(PlayerStat[playerid][BoomBoxLink], 512, "http://www.sky.fm/mp3/tophits.pls");
  175.                         SendClientMessage(playerid, GREEN, "Radio station changed.");
  176.                         for(new i = 0; i < MAX_PLAYERS; i++)
  177.                         {
  178.                             if(IsPlayerInRangeOfPoint(i, 20.0, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]))
  179.                             {
  180.                                 PlayAudioStreamForPlayer(i, PlayerStat[i][BoomBoxLink], PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ], 10.0, 1);
  181.                             }
  182.                         }
  183.                     }
  184.                 }
  185.             }
  186.         }
  187.     }
  188.     return 1;
  189. }
  190.  
  191.  
  192. //-----------------------------------------------------------------------[Commands]------------------------------------------------------------------------------
  193. COMMAND:boombox(playerid, params[])
  194. {
  195.     if(PlayerStat[playerid][BoomBoxStatus] == playerid) return SendClientMessage(playerid, GREY, "You can't use this command now.");
  196.     if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, GREY, "You can't use this command now.");
  197.     ShowPlayerDialog(playerid, 8888, DIALOG_STYLE_LIST, "Radio Stations:","SomaFM\nSkyFM","Play","Quit");
  198.     return 1;
  199. }
  200.  
  201. COMMAND:radiostation(playerid, params[])
  202. {
  203.     if(PlayerStat[playerid][BoomBoxStatus] == -1) return SendClientMessage(playerid, GREY, "You can't use this command now.");
  204.     ShowPlayerDialog(playerid, 8888, DIALOG_STYLE_LIST, "Radio Stations:","SomaFM\nWWOZ","Play","Quit");
  205.     return 1;
  206. }
  207.  
  208. COMMAND:turnoff(playerid, params[])
  209. {
  210.     if(PlayerStat[playerid][BoomBoxStatus] == -1) return SendClientMessage(playerid, GREY, "You can't use this command now.");
  211.     SendClientMessage(playerid, RED, "Boombox turned [OFF].");
  212.     DestroyDynamicObject(PlayerStat[playerid][BoomBoxObject]);
  213.     StopAudioStreamForPlayer(playerid);
  214.     PlayerStat[playerid][BoomBoxStatus] = -1;
  215.     for(new i = 0; i < MAX_PLAYERS; i++)
  216.     {
  217.         if(IsPlayerInRangeOfPoint(i, 20.0, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]))
  218.         {
  219.             StopAudioStreamForPlayer(i);
  220.             PlayerStat[i][ListeningToBoomBox] = -1;
  221.         }
  222.     }
  223.     return 1;
  224. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement