Ghecco

Untitled

Jan 12th, 2022
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.22 KB | None | 0 0
  1. #include <YSI_Coding\y_hooks>
  2.  
  3. static stock const urls[][] = {
  4. "",
  5. "https://s2.radio.co/s2b2b68744/listen",
  6. "https://streams.ilovemusic.de/iloveradio1.mp3",
  7. "https://streams.ilovemusic.de/iloveradio2.mp3",
  8. "https://streams.ilovemusic.de/iloveradio21.mp3",
  9. "http://streams.ilovemusic.de/iloveradio5.mp3",
  10. "http://blackbeats.fm/listen.m3u",
  11. "http://server1.chilltrax.com:9000/listen.pls",
  12. "http://stream.radioparadise.com/mp3-320",
  13. "http://listener3.mp3.tb-group.fm/ht.mp3",
  14. "http://listener1.mp3.tb-group.fm/hb.mp3",
  15. "http://listener2.mp3.tb-group.fm/trb.mp3",
  16. "http://listener2.mp3.tb-group.fm/ct.mp3",
  17. "http://listener3.mp3.tb-group.fm/clt.mp3",
  18. "http://listener1.mp3.tb-group.fm/tb.mp3",
  19. "http://listener3.mp3.tb-group.fm/tt.mp3",
  20. "https://www.surfmusik.de/m3u/1-fm-reggae-trade,16149.m3u",
  21. "http://cdn.nrjaudio.fm/adwz1/de/33041/mp3_128.mp3",
  22. "https://f5-pa6.nrjaudio.fm/de/56252/mp3_128.mp3?cdn_path=adswizz_lbs12&adws_out_b2&access_token=1893924e77484d839ad401fb79d794a9"
  23. },
  24. names[][] = {
  25. "Custom URL",
  26. "Badradio.nz",
  27. "iLoveRadio",
  28. "iLoveDance",
  29. "iLoveHardstyle",
  30. "iLoveMashup",
  31. "BlackBeats.FM",
  32. "Chilltrax",
  33. "Radio Paradise",
  34. "HouseTime.FM",
  35. "HardBase.FM",
  36. "TranceBase.FM",
  37. "CoreTime.FM",
  38. "ClubTime.FM",
  39. "TechnoBase.FM",
  40. "TeaTime",
  41. "Reggae",
  42. "Energy RAP US"
  43. };
  44.  
  45. CMD:boombox(playerid, params[])
  46. {
  47. if(!pInfo[playerid][pVip]) return NO_VIP;
  48. if(GetPlayerVirtualWorld(playerid) >= 50) return NO_ARENA;
  49. if(pInfo[playerid][pJail]) return SendClientMessage(playerid,rot,!"* You can not use this command, because you are in jail!");
  50. if(GetPlayerVirtualWorld(playerid) != 0) return SendClientMessage(playerid,rot,!"* You can only use this command outside!");
  51. if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid,rot,!"* You must be on foot to do this.");
  52. if(GetPVarType(playerid, "pBoomBox")) return SendClientMessage(playerid,rot,!"* You already have a boombox out, use /destroyboombox.");
  53.  
  54. foreach(new i : Player)
  55. {
  56. if(GetPVarType(i, "pBoomBox"))
  57. {
  58. if(IsPlayerInRangeOfPoint(playerid, 30.0, GetPVarFloat(i, "pBoomBoxX"), GetPVarFloat(i, "pBoomBoxY"), GetPVarFloat(i, "pBoomBoxZ")))
  59. {
  60. SendClientMessage(playerid,rot,!"* You are in range of another boombox, you can't place one here!");
  61. return 1;
  62. }
  63. }
  64. }
  65.  
  66.  
  67. new Float:x, Float:y, Float:z, Float:a;
  68. GetPlayerPos(playerid, x, y, z);
  69. GetPlayerFacingAngle(playerid, a);
  70. ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_In", 4.0, 0, 0, 0, 0, 0, 1);
  71. x += (2 * floatsin(-a, degrees));
  72. y += (2 * floatcos(-a, degrees));
  73. z -= 1.0;
  74.  
  75. DestroyBoombox(playerid);
  76. SetPVarInt(playerid, "pBoomBox", CreateDynamicObject(2103, x, y, z, 0.0, 0.0, a, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
  77. SetPVarFloat(playerid, "pBoomBoxX", x); SetPVarFloat(playerid, "pBoomBoxY", y); SetPVarFloat(playerid, "pBoomBoxZ", z);
  78.  
  79. new string[255];
  80. format(string, sizeof(string), "%s's boombox\n/setboombox or\n/destroyboombox", GetPlayerNameEx(playerid));
  81. SetPVarInt(playerid, "pBoomBoxLabel", _:CreateDynamic3DTextLabel(string, yellow, x, y, z+0.6, 5.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
  82. SetPVarInt(playerid, "pBoomBoxArea", CreateDynamicSphere(x, y, z, 30.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)));
  83. SetPVarInt(playerid, "pBoomBoxInt", GetPlayerInterior(playerid));
  84. SetPVarInt(playerid, "pBoomBoxVW", GetPlayerVirtualWorld(playerid));
  85.  
  86. Streamer_SetIntData(STREAMER_TYPE_AREA , GetPVarInt(playerid, "pBoomBoxArea"), E_STREAMER_EXTRA_ID, playerid);
  87.  
  88. SendClientMessage(playerid, grey, "* You have placed an boombox!");
  89. ShowBoomboxMenu(playerid);
  90. return 1;
  91. }
  92.  
  93. CMD:destroyboombox(playerid, params[])
  94. {
  95. if(!GetPVarType(playerid, "pBoomBox")) return SendClientMessage(playerid,rot,!"* You dont have a boombox out, to place one use /boombox.");
  96. if(!IsPlayerInDynamicArea(playerid, GetPVarInt(playerid, "pBoomBoxArea"), 1)) return SendClientMessage(playerid,rot,!"* You must be near your boombox.");
  97.  
  98. DestroyBoombox(playerid);
  99. return 1;
  100. }
  101.  
  102. CMD:setboombox(playerid, params[])
  103. {
  104. if(!pInfo[playerid][pVip]) return NO_VIP;
  105. if(!GetPVarType(playerid, "pBoomBox")) return SendClientMessage(playerid,rot,!"* You dont have a boombox out, to place one use /boombox.");
  106. if(!IsPlayerInDynamicArea(playerid, GetPVarInt(playerid, "pBoomBoxArea"), 1)) return SendClientMessage(playerid,rot,!"* You must be near your boombox.");
  107.  
  108. ShowBoomboxMenu(playerid);
  109. return 1;
  110. }
  111.  
  112. DestroyBoombox(playerid)
  113. {
  114. if(GetPVarType(playerid, "pBoomBox"))
  115. {
  116. foreach(new i : Player)
  117. {
  118. if(IsPlayerInRangeOfPoint(i, 30.0, GetPVarFloat(playerid, "pBoomBoxX"), GetPVarFloat(playerid, "pBoomBoxY"), GetPVarFloat(playerid, "pBoomBoxZ")) && GetPVarInt(i, "pBoomBoxListeningTo") == playerid)
  119. {
  120. StopAudioStreamForPlayer(i);
  121. DeletePVar(i, "pBoomBoxListeningTo");
  122. }
  123. }
  124.  
  125. if(IsValidDynamicObject(GetPVarInt(playerid, "pBoomBox"))) DestroyDynamicObject(GetPVarInt(playerid, "pBoomBox")), DeletePVar(playerid, "pBoomBox");
  126. if(IsValidDynamic3DTextLabel(Text3D:GetPVarInt(playerid, "pBoomBoxLabel"))) DestroyDynamic3DTextLabel(Text3D:GetPVarInt(playerid, "pBoomBoxLabel")), DeletePVar(playerid, "pBoomBoxLabel");
  127. if(IsValidDynamicArea(GetPVarInt(playerid, "pBoomBoxArea"))) DestroyDynamicArea(GetPVarInt(playerid, "pBoomBoxArea")), DeletePVar(playerid, "pBoomBoxArea");
  128. DeletePVar(playerid, "pBoomBoxX");
  129. DeletePVar(playerid, "pBoomBoxY");
  130. DeletePVar(playerid, "pBoomBoxZ");
  131. DeletePVar(playerid, "pBoomBoxInt");
  132. DeletePVar(playerid, "pBoomBoxVW");
  133. DeletePVar(playerid, "pBoomBoxStation");
  134. DeletePVar(playerid, "pBoomBoxDestructionTimer");
  135. }
  136. return 1;
  137. }
  138.  
  139. hook OnPlayerEnterDynArea(playerid, areaid)
  140. {
  141. if(IsPlayerNPC(playerid)) return 1;
  142. new boomboxOwner = Streamer_GetIntData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID);
  143. if(boomboxOwner == playerid && GetPVarInt(playerid, "pBoomBoxDestructionTimer"))
  144. {
  145. KillTimer(GetPVarInt(playerid, "pBoomBoxDestructionTimer"));
  146. DeletePVar(playerid, "pBoomBoxDestructionTimer");
  147. }
  148. if(IsPlayerConnected(boomboxOwner) && GetPVarType(boomboxOwner, "pBoomBox") && !GetPVarType(playerid, "radio"))
  149. {
  150. new url[300];
  151. GetPVarString(boomboxOwner, "pBoomBoxStation", url, sizeof url);
  152. PlayAudioStreamForPlayer(playerid, url, GetPVarFloat(boomboxOwner, "pBoomBoxX"), GetPVarFloat(boomboxOwner, "pBoomBoxY"), GetPVarFloat(boomboxOwner, "pBoomBoxZ"), 30.0, 1);
  153. SetPVarInt(playerid, "pBoomBoxListeningTo", boomboxOwner);
  154. }
  155. return 1;
  156. }
  157.  
  158. hook OnPlayerLeaveDynArea(playerid, areaid)
  159. {
  160. if(IsPlayerNPC(playerid)) return 1;
  161. new boomboxOwner = Streamer_GetIntData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID);
  162. if(IsPlayerConnected(boomboxOwner) && GetPVarType(boomboxOwner, "pBoomBox") && GetPVarInt(playerid, "pBoomBoxListeningTo") == boomboxOwner)
  163. {
  164. StopAudioStreamForPlayer(playerid);
  165. DeletePVar(playerid, "pBoomBoxListeningTo");
  166.  
  167. if(boomboxOwner == playerid)
  168. {
  169.  
  170. new timerid = SetTimerEx(DestroyBoombox, 10000, false, playerid);
  171. SetPVarInt(playerid, "pBoomBoxDestructionTimer", timerid);
  172. SendClientMessage(playerid, grey, "* You are far from your boombox, in 10 seconds it disappears if you don't come back close!");
  173. }
  174. return 1;
  175. }
  176.  
  177. hook OnPlayerDisconnect(playerid, reason)
  178. {
  179. if(IsPlayerNPC(playerid)) return 1;
  180. DestroyBoombox(playerid);
  181. return 1;
  182. }
  183.  
  184. stock ShowBoomboxMenu(playerid)
  185. {
  186. inline BoomboxMenu(pid, did, response, listitem, string:inputtext[])
  187. {
  188. #pragma unused pid, did, listitem, inputtext
  189. if(response)
  190. {
  191. if(listitem == 0) return ShowBoomboxCustomUrlMenu(playerid);
  192.  
  193. foreach(new i : Player)
  194. {
  195. if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "pBoomBoxArea")) && !GetPVarType(i, "radio"))
  196. {
  197. SetPVarInt(i, "pBoomBoxListeningTo", playerid);
  198. PlayAudioStreamForPlayer(i, urls[listitem], GetPVarFloat(playerid, "pBoomBoxX"), GetPVarFloat(playerid, "pBoomBoxY"), GetPVarFloat(playerid, "pBoomBoxZ"), 30.0, 1);
  199. }
  200. }
  201. SetPVarString(playerid, "pBoomBoxStation", urls[listitem]);
  202. }
  203. }
  204.  
  205. new string[sizeof(names)*12 + 24];
  206. for(new i; i<sizeof(names); i++) format(string,sizeof(string),"%s%s\n",string,names[i]);
  207. Dialog_ShowCallback(playerid, using inline BoomboxMenu, DIALOG_STYLE_LIST, DC"Boombox | Play Music", string, "Select", "Cancel");
  208. return 1;
  209. }
  210.  
  211. stock ShowBoomboxCustomUrlMenu(playerid)
  212. {
  213. inline CustomBoomboxUrlMenu(pid, did, response, listitem, string:inputtext[])
  214. {
  215. if(response)
  216. {
  217. #pragma unused pid, did, listitem, inputtext
  218. foreach(new i : Player)
  219. {
  220. if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "pBoomBoxArea")))
  221. {
  222. SetPVarInt(i, "pBoomBoxListeningTo", playerid);
  223. PlayAudioStreamForPlayer(i, inputtext, GetPVarFloat(playerid, "pBoomBoxX"), GetPVarFloat(playerid, "pBoomBoxY"), GetPVarFloat(playerid, "pBoomBoxZ"), 30.0, 1);
  224. }
  225. }
  226. SetPVarString(playerid, "pBoomBoxStation", inputtext);
  227. }
  228. }
  229. Dialog_ShowCallback(playerid, using inline CustomBoomboxUrlMenu, DIALOG_STYLE_INPUT, DC"Boombox | Play From URL", "Please Enter the URL link below.\nIt is recommended the link is live streamed for continuous playback.", "Enter", "Cancel");
  230. return 1;
  231. }
  232.  
Advertisement
Add Comment
Please, Sign In to add comment