Advertisement
Guest User

Radio Filterscript

a guest
Dec 23rd, 2011
1,290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.08 KB | None | 0 0
  1. /*
  2.     Default-Style radio stream system
  3.     @Author: Bitrate
  4.     http://forum.sa-mp.com/member.php?u=143266
  5. */
  6.  
  7. #include <a_samp>
  8.  
  9. #define MAX_STATIONS 5
  10.  
  11. #define PRESSED(%0) \
  12.         (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  13.  
  14.  
  15.  
  16. new Text:pRadioStation[MAX_PLAYERS] = {Text:INVALID_TEXT_DRAW, ...};
  17. new HideTimer[MAX_PLAYERS];
  18.  
  19. forward UpdateStation(playerid, StationiD);
  20. forward RadioText(playerid);
  21.  
  22.  
  23.  
  24. public OnFilterScriptInit()
  25. {
  26.     print("\n--------------------------------------");
  27.     print(" Vehicle radio system by Bitrate.\n");
  28.     print("--------------------------------------\n");
  29.     return 1;
  30. }
  31.  
  32. public OnFilterScriptExit()
  33. {
  34.     return 1;
  35. }
  36.  
  37. public OnPlayerConnect(playerid)
  38. {
  39.     pRadioStation[playerid] = TextDrawCreate(220, 25, "Radio off");
  40.    
  41.     TextDrawFont(pRadioStation[playerid], 2);
  42.    
  43.     TextDrawUseBox(pRadioStation[playerid], 0);
  44.    
  45.     TextDrawLetterSize(pRadioStation[playerid], 0.7, 1.3);
  46.    
  47.     TextDrawFont(pRadioStation[playerid], 2);
  48.    
  49.     TextDrawSetShadow(pRadioStation[playerid],0);
  50.    
  51.     TextDrawSetOutline(pRadioStation[playerid],1);
  52.    
  53.     TextDrawColor(pRadioStation[playerid],0x946110FF);
  54.    
  55.     return 1;
  56. }
  57.  
  58. public OnPlayerDisconnect(playerid, reason)
  59. {
  60.     return 1;
  61. }
  62.  
  63. public OnPlayerStateChange(playerid, newstate, oldstate)
  64. {
  65.     if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
  66.     {
  67.         SendClientMessage(playerid, 0xFF0000FF, "To select the next radio press ~k~~CONVERSATION_YES~ and to select the prior radio press ~k~~CONVERSATION_NO~");
  68.  
  69.         UpdateStation(playerid, 1);
  70.     }
  71.     else if(newstate != PLAYER_STATE_DRIVER || newstate != PLAYER_STATE_PASSENGER && oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
  72.     {
  73.         StopAudioStreamForPlayer(playerid);
  74.     }
  75.    
  76.     return 1;
  77. }
  78.  
  79. public OnPlayerExitVehicle(playerid, vehicleid)
  80. {
  81.     return 1;
  82. }
  83.  
  84. public UpdateStation(playerid, StationiD)
  85. {
  86.     if(StationiD == 0)
  87.     {
  88.         KillTimer(HideTimer[playerid]);
  89.    
  90.         StopAudioStreamForPlayer(playerid);
  91.  
  92.         SetPVarInt(playerid, "StationiD", 0);
  93.  
  94.         TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
  95.         TextDrawSetString(pRadioStation[playerid], "Radio Off");
  96.  
  97.         HideTimer[playerid] = SetTimerEx("RadioText", 3000, false, "i", playerid);
  98.     }
  99.     if(StationiD == 1)
  100.     {
  101.         KillTimer(HideTimer[playerid]);
  102.    
  103.         PlayAudioStreamForPlayer(playerid, "http://tx.whatson.com/icecast.php?i=hits.mp3.m3u");
  104.        
  105.         SetPVarInt(playerid, "StationiD", 1);
  106.        
  107.         TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
  108.         TextDrawSetString(pRadioStation[playerid], "The Hits Radio");
  109.        
  110.         HideTimer[playerid] = SetTimerEx("RadioText", 3000, false, "i", playerid);
  111.     }
  112.     else if(StationiD == 2)
  113.     {
  114.         KillTimer(HideTimer[playerid]);
  115.    
  116.         PlayAudioStreamForPlayer(playerid, "http://tx.whatson.com/icecast.php?i=metro.mp3.m3u");
  117.        
  118.         SetPVarInt(playerid, "StationiD", 2);
  119.        
  120.         TextDrawSetString(pRadioStation[playerid], "Metro");
  121.         TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
  122.        
  123.         HideTimer[playerid] = SetTimerEx("RadioText", 3000, false, "i", playerid);
  124.     }
  125.     else if(StationiD == 3)
  126.     {
  127.         KillTimer(HideTimer[playerid]);
  128.    
  129.         PlayAudioStreamForPlayer(playerid, "http://tx.whatson.com/icecast.php?i=kerrang.mp3.m3u");
  130.        
  131.         SetPVarInt(playerid, "StationiD", 3);
  132.        
  133.         TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
  134.         TextDrawSetString(pRadioStation[playerid], "Kerrang");
  135.        
  136.         HideTimer[playerid] = SetTimerEx("RadioText", 3000, false, "i", playerid);
  137.     }
  138.     else if(StationiD == 4)
  139.     {
  140.         KillTimer(HideTimer[playerid]);
  141.    
  142.         PlayAudioStreamForPlayer(playerid, "http://tx.whatson.com/icecast.php?i=magic1054.mp3.m3u");
  143.        
  144.         SetPVarInt(playerid, "StationiD", 4);
  145.        
  146.         TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
  147.         TextDrawSetString(pRadioStation[playerid], "Magic 105.4");
  148.        
  149.         HideTimer[playerid] = SetTimerEx("RadioText", 3000, false, "i", playerid);
  150.     }
  151.     else if(StationiD == 5)
  152.     {
  153.         KillTimer(HideTimer[playerid]);
  154.  
  155.         PlayAudioStreamForPlayer(playerid, "http://tx.whatson.com/icecast.php?i=smashhits.mp3.m3u");
  156.  
  157.         SetPVarInt(playerid, "StationiD", 5);
  158.  
  159.         TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
  160.         TextDrawSetString(pRadioStation[playerid], "Smash Hits");
  161.  
  162.         HideTimer[playerid] = SetTimerEx("RadioText", 3000, false, "i", playerid);
  163.     }
  164.    
  165.     return 1;
  166. }
  167.  
  168. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  169. {
  170.     if(IsPlayerInAnyVehicle(playerid))
  171.     {
  172.         if(PRESSED(KEY_YES))
  173.         {
  174.             if(GetPVarInt(playerid, "StationiD") >= MAX_STATIONS) SetPVarInt(playerid, "StationiD", -1);
  175.            
  176.             UpdateStation(playerid, GetPVarInt(playerid, "StationiD") + 1);
  177.         }
  178.         else if(PRESSED(KEY_NO))
  179.         {
  180.             if(GetPVarInt(playerid, "StationiD") <= 0) SetPVarInt(playerid, "StationiD", MAX_STATIONS + 1);
  181.            
  182.             UpdateStation(playerid, GetPVarInt(playerid, "StationiD") - 1);
  183.         }
  184.     }
  185.    
  186.     return 1;
  187. }
  188.  
  189. public RadioText(playerid)
  190. {
  191.     TextDrawHideForPlayer(playerid, pRadioStation[playerid]);
  192. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement