Advertisement
Guest User

Riddick - Radio edited

a guest
Dec 24th, 2011
526
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 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) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  12.  
  13. new Text:pRadioStation[MAX_PLAYERS] = {Text:INVALID_TEXT_DRAW, ...};
  14. new HideTimer[MAX_PLAYERS];
  15.  
  16. forward UpdateStation(playerid, StationiD);
  17. forward RadioText(playerid);
  18.  
  19. public OnFilterScriptInit()
  20. {
  21. print("\n--------------------------------------");
  22. print(" Vehicle radio system by Bitrate.\n");
  23. print("--------------------------------------\n");
  24. return true;
  25. }
  26.  
  27. public OnPlayerConnect(playerid)
  28. {
  29. pRadioStation[playerid] = TextDrawCreate(220, 25, "Radio off");
  30. TextDrawFont(pRadioStation[playerid], 2);
  31. TextDrawUseBox(pRadioStation[playerid], 0);
  32. TextDrawLetterSize(pRadioStation[playerid], 0.7, 1.3);
  33. TextDrawFont(pRadioStation[playerid], 2);
  34. TextDrawSetShadow(pRadioStation[playerid],0);
  35. TextDrawSetOutline(pRadioStation[playerid],1);
  36. TextDrawColor(pRadioStation[playerid],0x946110FF);
  37. return true;
  38. }
  39.  
  40. public OnPlayerStateChange(playerid, newstate, oldstate)
  41. {
  42. if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
  43. {
  44. SendClientMessage(playerid, 0xFF0000FF, "To select the next radio press ~k~~CONVERSATION_YES~ and to select the previous radio press ~k~~CONVERSATION_NO~");
  45. UpdateStation(playerid, 1);
  46. }
  47.  
  48. else if(newstate != PLAYER_STATE_DRIVER || newstate != PLAYER_STATE_PASSENGER && oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
  49. {
  50. StopAudioStreamForPlayer(playerid);
  51. }
  52. return true;
  53. }
  54.  
  55. public UpdateStation(playerid, StationiD)
  56. {
  57. switch(StationiD)
  58. {
  59. case 0:
  60. {
  61. StopAudioStreamForPlayer(playerid);
  62. SetPVarInt(playerid, "StationiD", 0);
  63. TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
  64. TextDrawSetString(pRadioStation[playerid], "Radio Off");
  65. }
  66.  
  67. case 1:
  68. {
  69. PlayAudioStreamForPlayer(playerid, "http://tx.whatson.com/icecast.php?i=hits.mp3.m3u");
  70. SetPVarInt(playerid, "StationiD", 1);
  71. TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
  72. TextDrawSetString(pRadioStation[playerid], "The Hits Radio");
  73. }
  74.  
  75. case 2:
  76. {
  77. PlayAudioStreamForPlayer(playerid, "http://tx.whatson.com/icecast.php?i=metro.mp3.m3u");
  78. SetPVarInt(playerid, "StationiD", 2);
  79. TextDrawSetString(pRadioStation[playerid], "Metro");
  80. TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
  81. }
  82.  
  83. case 3:
  84. {
  85. PlayAudioStreamForPlayer(playerid, "http://tx.whatson.com/icecast.php?i=kerrang.mp3.m3u");
  86. SetPVarInt(playerid, "StationiD", 3);
  87. TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
  88. TextDrawSetString(pRadioStation[playerid], "Kerrang");
  89. }
  90.  
  91. case 4:
  92. {
  93. PlayAudioStreamForPlayer(playerid, "http://tx.whatson.com/icecast.php?i=magic1054.mp3.m3u");
  94. SetPVarInt(playerid, "StationiD", 4);
  95. TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
  96. TextDrawSetString(pRadioStation[playerid], "Magic 105.4");
  97. }
  98.  
  99. case 5:
  100. {
  101. PlayAudioStreamForPlayer(playerid, "http://tx.whatson.com/icecast.php?i=smashhits.mp3.m3u");
  102. SetPVarInt(playerid, "StationiD", 5);
  103. TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
  104. TextDrawSetString(pRadioStation[playerid], "Smash Hits");
  105. }
  106. }
  107.  
  108. KillTimer(HideTimer[playerid]);
  109. HideTimer[playerid] = SetTimerEx("RadioText", 3000, false, "i", playerid);
  110. return true;
  111. }
  112.  
  113. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  114. {
  115. if(IsPlayerInAnyVehicle(playerid))
  116. {
  117. if(PRESSED(KEY_YES))
  118. {
  119. if(GetPVarInt(playerid, "StationiD") >= MAX_STATIONS) SetPVarInt(playerid, "StationiD", -1);
  120.  
  121. UpdateStation(playerid, GetPVarInt(playerid, "StationiD") + 1);
  122. }
  123.  
  124. else if(PRESSED(KEY_NO))
  125. {
  126. if(GetPVarInt(playerid, "StationiD") <= 0) SetPVarInt(playerid, "StationiD", MAX_STATIONS + 1);
  127.  
  128. UpdateStation(playerid, GetPVarInt(playerid, "StationiD") - 1);
  129. }
  130. }
  131. return true;
  132. }
  133.  
  134. public RadioText(playerid)
  135. {
  136. return TextDrawHideForPlayer(playerid, pRadioStation[playerid]);
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement