Advertisement
silverms

Simple Radio System

Feb 10th, 2017
701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.67 KB | None | 0 0
  1. #include a_samp
  2. #include zcmd
  3. #include sscanf2
  4. //this is simple car radio system made by silverms
  5. #define COLOR_YELLOW 0xFFFF00AA
  6. new Radio[MAX_PLAYERS];
  7.  
  8. public OnPlayerConnect(playerid)
  9. {
  10. if(Radio[playerid] == 1)
  11. {
  12. Radio[playerid] = 0;
  13. StopAudioStreamForPlayer(playerid);
  14. }
  15. return 1;
  16. }
  17. public OnPlayerExitVehicle(playerid, vehicleid)
  18. {
  19. if(Radio[playerid] == 1)
  20. {
  21. Radio[playerid] = 0;
  22. StopAudioStreamForPlayer(playerid);
  23. }
  24. return 1;
  25. }
  26. public OnVehicleDeath(vehicleid, killerid)
  27. {
  28. if(Radio[killerid] == 1)
  29. {
  30. Radio[killerid] = 0;
  31. StopAudioStreamForPlayer(killerid);
  32. }
  33. return 1;
  34. }
  35. public OnPlayerStateChange(playerid, newstate, oldstate)
  36. {
  37. if(oldstate == PLAYER_STATE_DRIVER)
  38. {
  39. if(Radio[playerid] == 1)
  40. {
  41. Radio[playerid] = 0;
  42. StopAudioStreamForPlayer(playerid);
  43. }
  44. }
  45. if(oldstate == PLAYER_STATE_PASSENGER)
  46. {
  47. if(Radio[playerid] == 1)
  48. {
  49. Radio[playerid] = 0;
  50. StopAudioStreamForPlayer(playerid);
  51. }
  52. }
  53. }
  54. //the command
  55. CMD:radio(playerid, params[])
  56. {
  57. new option[128];
  58. if(sscanf(params, "s", option))
  59. {
  60. SendClientMessage(playerid, COLOR_YELLOW, "{FFFFFF} /radio [Option]");
  61. SendClientMessage(playerid, COLOR_YELLOW, "{FFFFFF} Options:URL, 0,1,2,3,4,5[0=clean bandit, 1=turn down for what, 2=Dont Let me down, 3=Faded, 4=IamTheOne,URL]");
  62. return 1;
  63. }
  64. {
  65.  
  66. if (strcmp(option, "0", true) == 0)
  67. {
  68. new vehicle = GetPlayerVehicleID(playerid);
  69. for(new i; i < MAX_PLAYERS; i++)
  70. {
  71. new playercar = GetPlayerVehicleID(i);
  72. if(playercar == vehicle)
  73. {
  74. Radio[i] = 1;
  75. PlayAudioStreamForPlayer(i, "http://rintixmusic.000webhostapp.com/music/cleanbandit.mp3");
  76. }
  77. }
  78. new changer[MAX_PLAYER_NAME+1], string[48+MAX_PLAYER_NAME+1];
  79. GetPlayerName(playerid, changer, sizeof(string));
  80. new Float:x, Float:y, Float:z;
  81. GetPlayerPos(playerid, x, y, z);
  82. for(new i2; i2 < MAX_PLAYERS; i2++)
  83. {
  84. if(IsPlayerInRangeOfPoint(i2, 10.0, x, y, z))
  85. {
  86. format(string, sizeof(string), "%s reaches for the car stereo and turns some knobs.", changer);
  87. SendClientMessage(i2, 0xC2A2DAAA, string);
  88. }
  89. }
  90. return 1;
  91. }
  92. if (strcmp(option, "1", true) == 0)
  93. {
  94. new vehicle = GetPlayerVehicleID(playerid);
  95. for(new i; i < MAX_PLAYERS; i++)
  96. {
  97. new playercar = GetPlayerVehicleID(i);
  98. if(playercar == vehicle)
  99. {
  100. Radio[i] = 1;
  101. PlayAudioStreamForPlayer(i, "http://rintixmusic.000webhostapp.com/music/turndown.mp3");
  102. }
  103. }
  104. new changer[MAX_PLAYER_NAME+1], string[48+MAX_PLAYER_NAME+1];
  105. GetPlayerName(playerid, changer, sizeof(string));
  106. new Float:x, Float:y, Float:z;
  107. GetPlayerPos(playerid, x, y, z);
  108. for(new i2; i2 < MAX_PLAYERS; i2++)
  109. {
  110. if(IsPlayerInRangeOfPoint(i2, 10.0, x, y, z))
  111. {
  112. format(string, sizeof(string), "%s reaches for the car stereo and turns some knobs.", changer);
  113. SendClientMessage(i2, 0xC2A2DAAA, string);
  114. }
  115. }
  116. return 1;
  117. }
  118. if (strcmp(option, "2", true) == 0)
  119. {
  120. new vehicle = GetPlayerVehicleID(playerid);
  121. for(new i; i < MAX_PLAYERS; i++)
  122. {
  123. new playercar = GetPlayerVehicleID(i);
  124. if(playercar == vehicle)
  125. {
  126. Radio[i] = 1;
  127. PlayAudioStreamForPlayer(i, "http://rintixmusic.000webhostapp.com/music/chain2.mp3");
  128. }
  129. }
  130. new changer[MAX_PLAYER_NAME+1], string[48+MAX_PLAYER_NAME+1];
  131. GetPlayerName(playerid, changer, sizeof(string));
  132. new Float:x, Float:y, Float:z;
  133. GetPlayerPos(playerid, x, y, z);
  134. for(new i2; i2 < MAX_PLAYERS; i2++)
  135. {
  136. if(IsPlayerInRangeOfPoint(i2, 10.0, x, y, z))
  137. {
  138. format(string, sizeof(string), "%s reaches for the car stereo and turns some knobs.", changer);
  139. SendClientMessage(i2, 0xC2A2DAAA, string);
  140. }
  141. }
  142. return 1;
  143. }
  144. if (strcmp(option, "3", true) == 0)
  145. {
  146. new vehicle = GetPlayerVehicleID(playerid);
  147. for(new i; i < MAX_PLAYERS; i++)
  148. {
  149. new playercar = GetPlayerVehicleID(i);
  150. if(playercar == vehicle)
  151. {
  152. Radio[i] = 1;
  153. PlayAudioStreamForPlayer(i, "http://rintixmusic.000webhostapp.com/music/faded.mp3");
  154. }
  155. }
  156. new changer[MAX_PLAYER_NAME+1], string[48+MAX_PLAYER_NAME+1];
  157. GetPlayerName(playerid, changer, sizeof(string));
  158. new Float:x, Float:y, Float:z;
  159. GetPlayerPos(playerid, x, y, z);
  160. for(new i2; i2 < MAX_PLAYERS; i2++)
  161. {
  162. if(IsPlayerInRangeOfPoint(i2, 10.0, x, y, z))
  163. {
  164. format(string, sizeof(string), "%s reaches for the car stereo and turns some knobs.", changer);
  165. SendClientMessage(i2, 0xC2A2DAAA, string);
  166. }
  167. }
  168. return 1;
  169. }
  170. if (strcmp(option, "4", true) == 0)
  171. {
  172. new vehicle = GetPlayerVehicleID(playerid);
  173. for(new i; i < MAX_PLAYERS; i++)
  174. {
  175. new playercar = GetPlayerVehicleID(i);
  176. if(playercar == vehicle)
  177. {
  178. Radio[i] = 1;
  179. PlayAudioStreamForPlayer(i, "http://rintixmusic.000webhostapp.com/music/iamtheone.mp3");
  180. }
  181. }
  182. new changer[MAX_PLAYER_NAME+1], string[48+MAX_PLAYER_NAME+1];
  183. GetPlayerName(playerid, changer, sizeof(string));
  184. new Float:x, Float:y, Float:z;
  185. GetPlayerPos(playerid, x, y, z);
  186. for(new i2; i2 < MAX_PLAYERS; i2++)
  187. {
  188. if(IsPlayerInRangeOfPoint(i2, 10.0, x, y, z))
  189. {
  190. format(string, sizeof(string), "%s reaches for the car stereo and turns some knobs.", changer);
  191. SendClientMessage(i2, 0xC2A2DAAA, string);
  192. }
  193. }
  194. return 1;
  195. }
  196. if(isnull(params)) return SendClientMessage(playerid, -1, "USAGE: /radio [url]");
  197. new vehicle = GetPlayerVehicleID(playerid);
  198. for(new i; i < MAX_PLAYERS; i++)
  199. {
  200. new playercar = GetPlayerVehicleID(i);
  201. if(playercar == vehicle)
  202. {
  203. Radio[i] = 1;
  204. PlayAudioStreamForPlayer(i, params);
  205. }
  206. }
  207. new changer[MAX_PLAYER_NAME+1], string[48+MAX_PLAYER_NAME+1];
  208. GetPlayerName(playerid, changer, sizeof(string));
  209. new Float:x, Float:y, Float:z;
  210. GetPlayerPos(playerid, x, y, z);
  211. for(new i2; i2 < MAX_PLAYERS; i2++)
  212. {
  213. if(IsPlayerInRangeOfPoint(i2, 10.0, x, y, z))
  214. {
  215. format(string, sizeof(string), "%s reaches for the car stereo and turns some knobs.", changer);
  216. SendClientMessage(i2, 0xC2A2DAAA, string);
  217. }
  218. }
  219. }
  220. return 1;
  221. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement