radio.pwn 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Radio System
  11. Next Generation Gaming, LLC
  12. (created by Next Generation Gaming Development Team)
  13. * Copyright (c) 2016, Next Generation Gaming, LLC
  14. *
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without modification,
  18. * are not permitted in any case.
  19. *
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #include <YSI\y_hooks>
  34. stock SendAudioURLToRange(url[], Float:x, Float:y, Float:z, Float:range)
  35. {
  36. audiourlid = CreateDynamicSphere(x, y, z, range);
  37. format(audiourlurl, sizeof(audiourlurl), "%s", url);
  38. audiourlparams[0] = x;
  39. audiourlparams[1] = y;
  40. audiourlparams[2] = z;
  41. audiourlparams[3] = range;
  42. return 1;
  43. }
  44. stock PlayerPlayMusic(playerid)
  45. {
  46. if(IsPlayerConnected(playerid)) {
  47. SetTimer("StopMusic", 5000, 0);
  48. PlayerPlaySound(playerid, 1068, 0.0, 0.0, 0.0);
  49. }
  50. }
  51. stock PlayerFixRadio(playerid)
  52. {
  53. if(IsPlayerConnected(playerid)) {
  54. SetTimer("PlayerFixRadio2", 1000, 0);
  55. PlayerPlaySound(playerid, 1068, 0.0, 0.0, 0.0);
  56. Fixr[playerid] = 1;
  57. }
  58. }
  59. forward RevisionListHTTP(index, response_code, data[]);
  60. public RevisionListHTTP(index, response_code, data[])
  61. {
  62. ShowPlayerDialogEx(index, DIALOG_REVISION, DIALOG_STYLE_LIST, "Current Version: "SERVER_GM_TEXT" -- View full changes at http://dev.ng-gaming.net", data, "Close", "");
  63. return 1;
  64. }
  65. forward StopMusic();
  66. public StopMusic()
  67. {
  68. foreach(new i: Player)
  69. {
  70. PlayerPlaySound(i, 1069, 0.0, 0.0, 0.0);
  71. }
  72. }
  73. forward PlayerFixRadio2();
  74. public PlayerFixRadio2()
  75. {
  76. foreach(new i: Player)
  77. {
  78. if(Fixr[i])
  79. {
  80. PlayerPlaySound(i, 1069, 0.0, 0.0, 0.0);
  81. Fixr[i] = 0;
  82. }
  83. }
  84. }
  85. stock PlayAudioStreamForPlayerEx(playerid, url[], Float:posX = 0.0, Float:posY = 0.0, Float:posZ = 0.0, Float:distance = 50.0, usepos = 0)
  86. {
  87. if(GetPVarType(playerid, "pAudioStream"))
  88. {
  89. SetPVarString(playerid, "pAudioStream", url);
  90. StopAudioStreamForPlayerEx(playerid, 1);
  91. }
  92. else SetPVarString(playerid, "pAudioStream", url);
  93. PlayAudioStreamForPlayer(playerid, url, posX, posY, posZ, distance, usepos);
  94. }
  95. stock StopAudioStreamForPlayerEx(playerid, reset = 0)
  96. {
  97. if(reset == 0) DeletePVar(playerid, "pAudioStream");
  98. StopAudioStreamForPlayer(playerid);
  99. }
  100. forward Top50HTTP(index, response_code, data[]);
  101. public Top50HTTP(index, response_code, data[])
  102. {
  103. DeletePVar(index, "pHTTPWait");
  104. if(response_code == 200)
  105. {
  106. ShowPlayerDialogEx(index,TOP50LIST,DIALOG_STYLE_LIST,"Top 50 Stations",data,"Select", "Back");
  107. }
  108. return 1;
  109. }
  110. forward Top50InfoHTTP(index, response_code, data[]);
  111. public Top50InfoHTTP(index, response_code, data[])
  112. {
  113. DeletePVar(index, "pHTTPWait");
  114. if(response_code == 200)
  115. {
  116. ShowPlayerDialogEx(index,TOP50LISTEN,DIALOG_STYLE_MSGBOX,"Station Info",data,"Listen", "Back");
  117. }
  118. return 1;
  119. }
  120. forward GenreHTTP(index, response_code, data[]);
  121. public GenreHTTP(index, response_code, data[])
  122. {
  123. DeletePVar(index, "pHTTPWait");
  124. if(response_code == 200)
  125. {
  126. ShowPlayerDialogEx(index,GENRES,DIALOG_STYLE_LIST,"Genres",data,"Select", "Back");
  127. }
  128. return 1;
  129. }
  130. forward StationListHTTP(index, response_code, data[]);
  131. public StationListHTTP(index, response_code, data[])
  132. {
  133. DeletePVar(index, "pHTTPWait");
  134. if(response_code == 200)
  135. {
  136. ShowPlayerDialogEx(index,STATIONLIST,DIALOG_STYLE_LIST,"Stations",data,"Select", "Back");
  137. }
  138. return 1;
  139. }
  140. forward StationInfoHTTP(index, response_code, data[]);
  141. public StationInfoHTTP(index, response_code, data[])
  142. {
  143. DeletePVar(index, "pHTTPWait");
  144. if(response_code == 200)
  145. {
  146. ShowPlayerDialogEx(index,STATIONLISTEN,DIALOG_STYLE_MSGBOX,"Station Info",data,"Listen", "Back");
  147. }
  148. return 1;
  149. }
  150. forward StationSearchHTTP(index, response_code, data[]);
  151. public StationSearchHTTP(index, response_code, data[])
  152. {
  153. DeletePVar(index, "pHTTPWait");
  154. HideNoticeGUIFrame(index);
  155. if(response_code == 200)
  156. {
  157. ShowPlayerDialogEx(index,STATIONSEARCHLIST,DIALOG_STYLE_LIST,"Stations",data,"Select", "Back");
  158. }
  159. return 1;
  160. }
  161. forward StationSearchInfoHTTP(index, response_code, data[]);
  162. public StationSearchInfoHTTP(index, response_code, data[])
  163. {
  164. DeletePVar(index, "pHTTPWait");
  165. HideNoticeGUIFrame(index);
  166. if(response_code == 200)
  167. {
  168. ShowPlayerDialogEx(index,STATIONSEARCHLISTEN,DIALOG_STYLE_MSGBOX,"Station Info",data,"Listen", "Back");
  169. }
  170. return 1;
  171. }
  172. forward StationSelectHTTP(index, response_code, data[]);
  173. public StationSelectHTTP(index, response_code, data[])
  174. {
  175. DeletePVar(index, "pHTTPWait");
  176. HideNoticeGUIFrame(index);
  177. if(response_code == 200)
  178. {
  179. if(IsPlayerInAnyVehicle(index))
  180. {
  181. foreach(new i: Player)
  182. {
  183. if(GetPlayerVehicleID(i) != 0 && GetPlayerVehicleID(i) == GetPlayerVehicleID(index)) {
  184. PlayAudioStreamForPlayerEx(i, data);
  185. }
  186. }
  187. format(stationidv[GetPlayerVehicleID(index)], 64, "%s", data);
  188. new string[53];
  189. format(string, sizeof(string), "* %s changes the radio station.", GetPlayerNameEx(index), string);
  190. ProxDetector(10.0, index, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  191. DeletePVar(index, "pSelectGenre");
  192. DeletePVar(index, "pSelectStation");
  193. }
  194. else if(GetPVarType(index, "pBoomBox"))
  195. {
  196. foreach(new i: Player)
  197. {
  198. if(IsPlayerInDynamicArea(i, GetPVarInt(index, "pBoomBoxArea")))
  199. {
  200. PlayAudioStreamForPlayerEx(i, data, GetPVarFloat(index, "pBoomBoxX"), GetPVarFloat(index, "pBoomBoxY"), GetPVarFloat(index, "pBoomBoxZ"), 30.0, 1);
  201. }
  202. }
  203. SetPVarString(index, "pBoomBoxStation", data);
  204. }
  205. else
  206. {
  207. PlayAudioStreamForPlayerEx(index, data);
  208. SetPVarInt(index, "MusicIRadio", 1);
  209. }
  210. }
  211. return 1;
  212. }
  213. stock ShowSetStation(playerid, title[] = "Radio Menu")
  214. {
  215. new string[256];
  216. format(string, sizeof(string), "Favorite Station\nGenres\nTop 50 Stations\nSearch\nK-LSR\nRadio New Robada\nNick's Radio\nCustom Audio URL\n%sTurn radio off", ((!isnull(PlayerInfo[playerid][pFavStation])) ? ("Favorite Station Settings\n") : ("")));
  217. return ShowPlayerDialogEx(playerid, SETSTATION, DIALOG_STYLE_LIST, title, string, "Select", "Close");
  218. }
  219. hook OnPlayerEnterDynamicArea(playerid, areaid) {
  220. //if(areaid == audiourlid) PlayAudioStreamForPlayerEx(playerid, audiourlurl, audiourlparams[0], audiourlparams[1], audiourlparams[2], audiourlparams[3], 1);
  221. if(areaid == GetGVarInt("MusicArea")) {
  222. PlayAudioStreamForPlayerEx(playerid, audiourlurl);
  223. }
  224. }
  225. hook OnPlayerLeaveDynamicArea(playerid, areaid) {
  226. //if(areaid == audiourlid) StopAudioStreamForPlayerEx(playerid);
  227. if(areaid == GetGVarInt("MusicArea")) StopAudioStreamForPlayerEx(playerid);
  228. }
  229. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  230. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  231. szMiscArray[0] = 0;
  232. if(dialogid == SETSTATION)
  233. {
  234. if(response)
  235. {
  236. if(listitem == 0)
  237. {
  238. if(isnull(PlayerInfo[playerid][pFavStation]))
  239. {
  240. if(GetPVarType(playerid, "pAudioStream")) ShowPlayerDialogEx(playerid, STATIONFAV, DIALOG_STYLE_MSGBOX, "Favorite Station", "You don't currently have a favorite station set.\n\nWould you like to set the one that is currently playing?", "Select", "Back");
  241. else ShowPlayerDialogEx(playerid, STATIONFAV2, DIALOG_STYLE_MSGBOX, "Favorite Station", "You don't currently have a favorite station set.\n\nPlease find a station and return to this menu to set a favorite station.", "Back", "");
  242. }
  243. else
  244. {
  245. if(IsPlayerInAnyVehicle(playerid))
  246. {
  247. foreach(new i: Player)
  248. {
  249. if(GetPlayerVehicleID(i) != 0 && GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid)) PlayAudioStreamForPlayerEx(i, PlayerInfo[playerid][pFavStation]);
  250. }
  251. format(stationidv[GetPlayerVehicleID(playerid)], 255, "%s", PlayerInfo[playerid][pFavStation]);
  252. format(szMiscArray, sizeof(szMiscArray), "* %s changes the radio station.", GetPlayerNameEx(playerid), szMiscArray);
  253. ProxDetector(10.0, playerid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  254. }
  255. else if(GetPVarType(playerid, "pBoomBox"))
  256. {
  257. foreach(new i: Player)
  258. {
  259. if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "pBoomBoxArea"))) PlayAudioStreamForPlayerEx(i, PlayerInfo[playerid][pFavStation], GetPVarFloat(playerid, "pBoomBoxX"), GetPVarFloat(playerid, "pBoomBoxY"), GetPVarFloat(playerid, "pBoomBoxZ"), 30.0, 1);
  260. }
  261. SetPVarString(playerid, "pBoomBoxStation", PlayerInfo[playerid][pFavStation]);
  262. }
  263. else
  264. {
  265. PlayAudioStreamForPlayerEx(playerid, PlayerInfo[playerid][pFavStation]);
  266. SetPVarInt(playerid, "MusicIRadio", 1);
  267. }
  268. }
  269. }
  270. if(listitem == 1)
  271. {
  272. if(!GetPVarType(playerid, "pHTTPWait"))
  273. {
  274. SetPVarInt(playerid, "pHTTPWait", 1);
  275. format(szMiscArray, sizeof(szMiscArray), "%s/radio/radio.php?listgenres=1", SAMP_WEB);
  276. HTTP(playerid, HTTP_GET, szMiscArray, "", "GenreHTTP");
  277. }
  278. else
  279. {
  280. SendClientMessage(playerid, 0xFFFFFFAA, "HTTP Thread is busy");
  281. }
  282. }
  283. else if(listitem == 2)
  284. {
  285. if(!GetPVarType(playerid, "pHTTPWait"))
  286. {
  287. SetPVarInt(playerid, "pHTTPWait", 1);
  288. format(szMiscArray, sizeof(szMiscArray), "%s/radio/radio.php?top50=1", SAMP_WEB);
  289. HTTP(playerid, HTTP_GET, szMiscArray, "", "Top50HTTP");
  290. }
  291. else
  292. {
  293. SendClientMessage(playerid, 0xFFFFFFAA, "HTTP Thread is busy");
  294. }
  295. }
  296. else if(listitem == 3)
  297. {
  298. ShowPlayerDialogEx(playerid,STATIONSEARCH,DIALOG_STYLE_INPUT,"Station Search","Input a search criteria:","Search","Back");
  299. }
  300. else if(listitem == 4)
  301. {
  302. if(IsPlayerInAnyVehicle(playerid))
  303. {
  304. foreach(new i: Player)
  305. {
  306. if(GetPlayerVehicleID(i) != 0 && GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid)) {
  307. PlayAudioStreamForPlayerEx(i, "http://shoutcast.ng-gaming.net:8000/listen.pls?sid=1");
  308. }
  309. }
  310. format(stationidv[GetPlayerVehicleID(playerid)], 64, "%s", "http://shoutcast.ng-gaming.net:8000/listen.pls?sid=1");
  311. format(szMiscArray, sizeof(szMiscArray), "* %s changes the radio station.", GetPlayerNameEx(playerid), szMiscArray);
  312. ProxDetector(10.0, playerid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  313. }
  314. else if(GetPVarType(playerid, "pBoomBox"))
  315. {
  316. foreach(new i: Player)
  317. {
  318. if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "pBoomBoxArea")))
  319. {
  320. PlayAudioStreamForPlayerEx(i, "http://shoutcast.ng-gaming.net:8000/listen.pls?sid=1", GetPVarFloat(playerid, "pBoomBoxX"), GetPVarFloat(playerid, "pBoomBoxY"), GetPVarFloat(playerid, "pBoomBoxZ"), 30.0, 1);
  321. }
  322. }
  323. SetPVarString(playerid, "pBoomBoxStation", "http://shoutcast.ng-gaming.net:8000/listen.pls?sid=1");
  324. }
  325. else
  326. {
  327. PlayAudioStreamForPlayerEx(playerid, "http://shoutcast.ng-gaming.net:8000/listen.pls?sid=1");
  328. SetPVarInt(playerid, "MusicIRadio", 1);
  329. }
  330. }
  331. else if(listitem == 5)
  332. {
  333. if(IsPlayerInAnyVehicle(playerid))
  334. {
  335. foreach(new i: Player)
  336. {
  337. if(GetPlayerVehicleID(i) != 0 && GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid)) {
  338. PlayAudioStreamForPlayerEx(i, "https://radio.newrobada.com/radio/8000/autodj.mp3");
  339. }
  340. }
  341. format(stationidv[GetPlayerVehicleID(playerid)], 64, "%s", "https://radio.newrobada.com/radio/8000/autodj.mp3");
  342. format(szMiscArray, sizeof(szMiscArray), "* %s changes the radio station.", GetPlayerNameEx(playerid), szMiscArray);
  343. ProxDetector(10.0, playerid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  344. }
  345. else if(GetPVarType(playerid, "pBoomBox"))
  346. {
  347. foreach(new i: Player)
  348. {
  349. if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "pBoomBoxArea")))
  350. {
  351. PlayAudioStreamForPlayerEx(i, "https://radio.newrobada.com/radio/8000/autodj.mp3", GetPVarFloat(playerid, "pBoomBoxX"), GetPVarFloat(playerid, "pBoomBoxY"), GetPVarFloat(playerid, "pBoomBoxZ"), 30.0, 1);
  352. }
  353. }
  354. SetPVarString(playerid, "pBoomBoxStation", "https://radio.newrobada.com/radio/8000/autodj.mp3");
  355. }
  356. else
  357. {
  358. PlayAudioStreamForPlayerEx(playerid, "https://radio.newrobada.com/radio/8000/autodj.mp3");
  359. SetPVarInt(playerid, "MusicIRadio", 1);
  360. }
  361. }
  362. else if(listitem == 6)
  363. {
  364. if(IsPlayerInAnyVehicle(playerid))
  365. {
  366. foreach(new i: Player)
  367. {
  368. if(GetPlayerVehicleID(i) != 0 && GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid)) {
  369. PlayAudioStreamForPlayerEx(i, "http://nick.ng-gaming.net:8000/listen.pls");
  370. }
  371. }
  372. format(stationidv[GetPlayerVehicleID(playerid)], 64, "%s", "http://nick.ng-gaming.net:8000/listen.pls");
  373. format(szMiscArray, sizeof(szMiscArray), "* %s changes the radio station.", GetPlayerNameEx(playerid), szMiscArray);
  374. ProxDetector(10.0, playerid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  375. }
  376. else if(GetPVarType(playerid, "pBoomBox"))
  377. {
  378. foreach(new i: Player)
  379. {
  380. if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "pBoomBoxArea")))
  381. {
  382. PlayAudioStreamForPlayerEx(i, "http://nick.ng-gaming.net:8000/listen.pls", GetPVarFloat(playerid, "pBoomBoxX"), GetPVarFloat(playerid, "pBoomBoxY"), GetPVarFloat(playerid, "pBoomBoxZ"), 30.0, 1);
  383. }
  384. }
  385. SetPVarString(playerid, "pBoomBoxStation", "http://nick.ng-gaming.net:8000/listen.pls");
  386. }
  387. else
  388. {
  389. PlayAudioStreamForPlayerEx(playerid, "http://nick.ng-gaming.net:8000/listen.pls");
  390. SetPVarInt(playerid, "MusicIRadio", 1);
  391. }
  392. }
  393. else if(listitem == 7)
  394. {
  395. ShowPlayerDialogEx(playerid, CUSTOM_URLCHOICE, DIALOG_STYLE_INPUT, "Custom URL", "Please insert a valid audio url stream.", "Enter", "Back");
  396. }
  397. else if(!isnull(PlayerInfo[playerid][pFavStation]) && listitem == 8)
  398. {
  399. ShowPlayerDialogEx(playerid, STATIONFAVSETTING, DIALOG_STYLE_LIST, "Favorite Station Settings", "Modify Station\nRemove Station", "Select", "Back");
  400. }
  401. else if((isnull(PlayerInfo[playerid][pFavStation]) && listitem == 8) || (!isnull(PlayerInfo[playerid][pFavStation]) && listitem == 9))
  402. {
  403. if(!IsPlayerInAnyVehicle(playerid))
  404. {
  405. if(GetPVarType(playerid, "pBoomBox"))
  406. {
  407. SendClientMessage(playerid, COLOR_WHITE, "You have turned off the boom box.");
  408. new Float:playerPos[3];
  409. GetPlayerPos(playerid, playerPos[0], playerPos[1], playerPos[2]);
  410. foreach(new i: Player)
  411. {
  412. if(IsPlayerInRangeOfPoint(i, 35, playerPos[0], playerPos[1], playerPos[2])) StopAudioStreamForPlayerEx(i);
  413. }
  414. DeletePVar(playerid, "pBoomBoxStation");
  415. }
  416. else
  417. {
  418. StopAudioStreamForPlayerEx(playerid);
  419. }
  420. }
  421. else
  422. {
  423. format(szMiscArray, sizeof(szMiscArray), "* %s turns off the radio.", GetPlayerNameEx(playerid), szMiscArray);
  424. ProxDetector(10.0, playerid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  425. foreach(new i: Player)
  426. {
  427. if(GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid)) {
  428. StopAudioStreamForPlayerEx(i);
  429. }
  430. }
  431. stationidv[GetPlayerVehicleID(playerid)][0] = 0;
  432. }
  433. }
  434. }
  435. }
  436. else if(dialogid == CUSTOM_URLCHOICE)
  437. {
  438. if(response)
  439. {
  440. if(isnull(inputtext) || IsNumeric(inputtext)) return SendClientMessageEx(playerid, COLOR_GRAD1, "You have not entered a valid URL.");
  441. if(IsPlayerInAnyVehicle(playerid))
  442. {
  443. foreach(new i: Player)
  444. {
  445. if(GetPlayerVehicleID(i) != 0 && GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid))
  446. {
  447. PlayAudioStreamForPlayerEx(i, inputtext);
  448. Log("logs/radiourl.log", inputtext);
  449. }
  450. }
  451. format(stationidv[GetPlayerVehicleID(playerid)], 64, "%s", inputtext);
  452. format(szMiscArray, sizeof(szMiscArray), "* %s changes the radio station.", GetPlayerNameEx(playerid));
  453. ProxDetector(10.0, playerid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  454. DeletePVar(playerid, "pSelectGenre");
  455. DeletePVar(playerid, "pSelectStation");
  456. }
  457. else if(GetPVarType(playerid, "pBoomBox"))
  458. {
  459. foreach(new i: Player)
  460. {
  461. if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "pBoomBoxArea")))
  462. {
  463. PlayAudioStreamForPlayerEx(i, inputtext, GetPVarFloat(playerid, "pBoomBoxX"), GetPVarFloat(playerid, "pBoomBoxY"), GetPVarFloat(playerid, "pBoomBoxZ"), 30.0, 1);
  464. }
  465. }
  466. SetPVarString(playerid, "pBoomBoxStation", inputtext);
  467. }
  468. else
  469. {
  470. PlayAudioStreamForPlayerEx(playerid, inputtext);
  471. SetPVarInt(playerid, "MusicIRadio", 1);
  472. //format(szMiscArray, sizeof(szMiscArray), "You are now playing %s", inputtext);
  473. //SendClientMessageEx(playerid, COLOR_GREEN, szMiscArray);
  474. }
  475. }
  476. else
  477. {
  478. ShowSetStation(playerid);
  479. }
  480. }
  481. else if(dialogid == GENRES)
  482. {
  483. if(response)
  484. {
  485. if(!GetPVarType(playerid, "pHTTPWait"))
  486. {
  487. format(szMiscArray, sizeof(szMiscArray), "%s/radio/radio.php?genre=%d", SAMP_WEB, (listitem+1));
  488. SetPVarInt(playerid, "pSelectGenre", (listitem+1));
  489. SetPVarInt(playerid, "pHTTPWait", 1);
  490. HTTP(playerid, HTTP_GET, szMiscArray, "", "StationListHTTP");
  491. }
  492. else
  493. {
  494. SendClientMessage(playerid, 0xFFFFFFAA, "HTTP Thread is busy");
  495. }
  496. }
  497. else
  498. {
  499. ShowSetStation(playerid);
  500. DeletePVar(playerid, "pSelectGenre");
  501. }
  502. }
  503. else if(dialogid == STATIONLIST)
  504. {
  505. if(response)
  506. {
  507. if(!GetPVarType(playerid, "pHTTPWait"))
  508. {
  509. format(szMiscArray, sizeof(szMiscArray), "%s/radio/radio.php?genre=%d&station=%d", SAMP_WEB, GetPVarInt(playerid, "pSelectGenre"), (listitem+1));
  510. SetPVarInt(playerid, "pHTTPWait", 1);
  511. SetPVarInt(playerid, "pSelectStation", (listitem+1));
  512. HTTP(playerid, HTTP_GET, szMiscArray, "", "StationInfoHTTP");
  513. }
  514. else
  515. {
  516. SendClientMessage(playerid, 0xFFFFFFAA, "HTTP Thread is busy");
  517. }
  518. }
  519. else
  520. {
  521. if(!GetPVarType(playerid, "pHTTPWait"))
  522. {
  523. SetPVarInt(playerid, "pHTTPWait", 1);
  524. format(szMiscArray, sizeof(szMiscArray), "%s/radio/radio.php?listgenres=1", SAMP_WEB);
  525. HTTP(playerid, HTTP_GET, szMiscArray, "", "GenreHTTP");
  526. }
  527. else
  528. {
  529. SendClientMessage(playerid, 0xFFFFFFAA, "HTTP Thread is busy");
  530. }
  531. }
  532. }
  533. else if(dialogid == TOP50LIST)
  534. {
  535. if(!response)
  536. {
  537. ShowSetStation(playerid);
  538. }
  539. else
  540. {
  541. if(!GetPVarType(playerid, "pHTTPWait"))
  542. {
  543. format(szMiscArray, sizeof(szMiscArray), "%s/radio/radio.php?top50=1&station=%d", SAMP_WEB, (listitem+1));
  544. SetPVarInt(playerid, "pHTTPWait", 1);
  545. SetPVarInt(playerid, "pSelectStation", (listitem+1));
  546. HTTP(playerid, HTTP_GET, szMiscArray, "", "Top50InfoHTTP");
  547. }
  548. else
  549. {
  550. SendClientMessage(playerid, 0xFFFFFFAA, "HTTP Thread is busy");
  551. }
  552. }
  553. }
  554. else if(dialogid == STATIONLISTEN)
  555. {
  556. if(response)
  557. {
  558. if(!GetPVarType(playerid, "pHTTPWait"))
  559. {
  560. format(szMiscArray, sizeof(szMiscArray), "%s/radio/radio.php?genre=%d&station=%d&listen=1", SAMP_WEB, GetPVarInt(playerid, "pSelectGenre"), GetPVarInt(playerid, "pSelectStation"));
  561. SetPVarInt(playerid, "pHTTPWait", 1);
  562. HTTP(playerid, HTTP_GET, szMiscArray, "", "StationSelectHTTP");
  563. }
  564. else
  565. {
  566. SendClientMessage(playerid, 0xFFFFFFAA, "HTTP Thread is busy");
  567. }
  568. }
  569. else
  570. {
  571. if(!GetPVarType(playerid, "pHTTPWait"))
  572. {
  573. format(szMiscArray, sizeof(szMiscArray), "%s/radio/radio.php?genre=%d", SAMP_WEB, GetPVarInt(playerid, "pSelectGenre"));
  574. SetPVarInt(playerid, "pHTTPWait", 1);
  575. HTTP(playerid, HTTP_GET, szMiscArray, "", "StationListHTTP");
  576. DeletePVar(playerid, "pSelectStation");
  577. }
  578. else
  579. {
  580. SendClientMessage(playerid, 0xFFFFFFAA, "HTTP Thread is busy");
  581. }
  582. }
  583. }
  584. else if(dialogid == TOP50LISTEN)
  585. {
  586. if(!response)
  587. {
  588. if(!GetPVarType(playerid, "pHTTPWait"))
  589. {
  590. DeletePVar(playerid, "pSelectStation");
  591. SetPVarInt(playerid, "pHTTPWait", 1);
  592. format(szMiscArray, sizeof(szMiscArray), "%s/radio/radio.php?top50=1", SAMP_WEB);
  593. HTTP(playerid, HTTP_GET, szMiscArray, "", "Top50HTTP");
  594. }
  595. else
  596. {
  597. SendClientMessage(playerid, 0xFFFFFFAA, "HTTP Thread is busy");
  598. }
  599. }
  600. else
  601. {
  602. if(!GetPVarType(playerid, "pHTTPWait"))
  603. {
  604. format(szMiscArray, sizeof(szMiscArray), "%s/radio/radio.php?top50=1&station=%d&listen=1", SAMP_WEB, GetPVarInt(playerid, "pSelectStation"));
  605. SetPVarInt(playerid, "pHTTPWait", 1);
  606. HTTP(playerid, HTTP_GET, szMiscArray, "", "StationSelectHTTP");
  607. }
  608. else
  609. {
  610. SendClientMessage(playerid, 0xFFFFFFAA, "HTTP Thread is busy");
  611. }
  612. }
  613. }
  614. else if(dialogid == STATIONSEARCH)
  615. {
  616. if(response)
  617. {
  618. if(strlen(inputtext) < 0 || strlen(inputtext) > 64)
  619. {
  620. ShowSetStation(playerid);
  621. }
  622. else
  623. {
  624. if(!GetPVarType(playerid, "pHTTPWait"))
  625. {
  626. format(szMiscArray, sizeof(szMiscArray), "%s/radio/radio.php?search=%s", SAMP_WEB, inputtext);
  627. SetPVarString(playerid, "pSearchStation", inputtext);
  628. SetPVarInt(playerid, "pHTTPWait", 1);
  629. ShowNoticeGUIFrame(playerid, 6);
  630. HTTP(playerid, HTTP_GET, szMiscArray, "", "StationSearchHTTP");
  631. }
  632. else
  633. {
  634. SendClientMessage(playerid, 0xFFFFFFAA, "HTTP Thread is busy");
  635. }
  636. }
  637. }
  638. else
  639. {
  640. ShowSetStation(playerid);
  641. }
  642. }
  643. else if(dialogid == STATIONSEARCHLIST)
  644. {
  645. if(response)
  646. {
  647. if(!GetPVarType(playerid, "pHTTPWait"))
  648. {
  649. GetPVarString(playerid, "pSearchStation", szMiscArray, sizeof(szMiscArray));
  650. format(szMiscArray, sizeof(szMiscArray), "%s/radio/radio.php?search=%s&station=%d", SAMP_WEB, szMiscArray, (listitem+1));
  651. SetPVarInt(playerid, "pHTTPWait", 1);
  652. ShowNoticeGUIFrame(playerid, 6);
  653. SetPVarInt(playerid, "pSelectStation", (listitem+1));
  654. HTTP(playerid, HTTP_GET, szMiscArray, "", "StationSearchInfoHTTP");
  655. }
  656. else
  657. {
  658. SendClientMessage(playerid, 0xFFFFFFAA, "HTTP Thread is busy");
  659. }
  660. }
  661. else
  662. {
  663. ShowSetStation(playerid);
  664. }
  665. }
  666. else if(dialogid == STATIONSEARCHLISTEN)
  667. {
  668. if(response)
  669. {
  670. if(!GetPVarType(playerid, "pHTTPWait"))
  671. {
  672. GetPVarString(playerid, "pSearchStation", szMiscArray, sizeof(szMiscArray));
  673. format(szMiscArray, sizeof(szMiscArray), "%s/radio/radio.php?search=%s&station=%d&listen=1", SAMP_WEB, szMiscArray, GetPVarInt(playerid, "pSelectStation"));
  674. SetPVarInt(playerid, "pHTTPWait", 1);
  675. ShowNoticeGUIFrame(playerid, 6);
  676. HTTP(playerid, HTTP_GET, szMiscArray, "", "StationSelectHTTP");
  677. }
  678. else
  679. {
  680. SendClientMessage(playerid, 0xFFFFFFAA, "HTTP Thread is busy");
  681. }
  682. }
  683. else
  684. {
  685. if(!GetPVarType(playerid, "pHTTPWait"))
  686. {
  687. GetPVarString(playerid, "pSearchStation", szMiscArray, sizeof(szMiscArray));
  688. format(szMiscArray, sizeof(szMiscArray), "%s/radio/radio.php?search=%s", SAMP_WEB, szMiscArray);
  689. ShowNoticeGUIFrame(playerid, 6);
  690. HTTP(playerid, HTTP_GET, szMiscArray, "", "StationSearchHTTP");
  691. DeletePVar(playerid, "pSelectStation");
  692. }
  693. else
  694. {
  695. SendClientMessage(playerid, 0xFFFFFFAA, "HTTP Thread is busy");
  696. }
  697. }
  698. }
  699. else if(dialogid == STATIONFAV)
  700. {
  701. if(response)
  702. {
  703. GetPVarString(playerid, "pAudioStream", PlayerInfo[playerid][pFavStation], 255);
  704. SendClientMessageEx(playerid, COLOR_WHITE, "You have successfully set your favorite station.");
  705. }
  706. else ShowSetStation(playerid);
  707. }
  708. else if(dialogid == STATIONFAV2)
  709. {
  710. ShowSetStation(playerid);
  711. }
  712. else if(dialogid == STATIONFAVSETTING)
  713. {
  714. switch(listitem)
  715. {
  716. case 0:
  717. {
  718. GetPVarString(playerid, "pAudioStream", PlayerInfo[playerid][pFavStation], 255);
  719. ShowPlayerDialogEx(playerid, STATIONFAVMODIFY, DIALOG_STYLE_MSGBOX, "Favorite Station", "You have successfully modified your favorite station!", "Go Back", "Exit");
  720. }
  721. case 1:
  722. {
  723. strcat((PlayerInfo[playerid][pFavStation][0] = 0, PlayerInfo[playerid][pFavStation]), "", 8);
  724. ShowPlayerDialogEx(playerid, STATIONREMOVE, DIALOG_STYLE_MSGBOX, "Favorite Station", "You have successfully removed your favorite station!", "Go Back", "Exit");
  725. }
  726. }
  727. if(!response) ShowSetStation(playerid);
  728. }
  729. else if(dialogid == STATIONFAVMODIFY)
  730. {
  731. if(response) ShowPlayerDialogEx(playerid, STATIONFAVSETTING, DIALOG_STYLE_LIST, "Favorite Station Settings", "Modify Station\nRemove Station", "Select", "Back");
  732. }
  733. else if(dialogid == STATIONREMOVE)
  734. {
  735. if(response) ShowSetStation(playerid);
  736. }
  737. return 0;
  738. }
  739. CMD:setstation(playerid, params[]) {
  740. if(!IsPlayerInAnyVehicle(playerid)) {
  741. return SendClientMessageEx(playerid, COLOR_GRAD2, "You must be in a car to use a car radio.");
  742. }
  743. ShowSetStation(playerid);
  744. return 1;
  745. }
  746. CMD:audiostopurl(playerid, params[])
  747. {
  748. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1) {
  749. if(IsValidDynamicArea(GetGVarInt("MusicArea")))
  750. {
  751. new string[128];
  752. foreach(new i: Player)
  753. {
  754. StopAudioStreamForPlayerEx(i);
  755. }
  756. DestroyDynamicArea(GetGVarInt("MusicArea"));
  757. DeleteGVar("MusicArea");
  758. DestroyDynamicArea(audiourlid);
  759. format(string,sizeof(string),"{AA3333}AdmWarning{FFFF00}: %s has stopped the audiourl",GetPlayerNameEx(playerid));
  760. ABroadCast(COLOR_YELLOW, string, 4);
  761. }
  762. else
  763. {
  764. SendClientMessage(playerid, COLOR_WHITE, "There is no audiourl to stop");
  765. }
  766. }
  767. else {
  768. SendClientMessageEx(playerid, COLOR_GRAD1, " You are not authorized to use that command !");
  769. return 1;
  770. }
  771. return 1;
  772. }
  773. CMD:audiourl(playerid, params[])
  774. {
  775. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1) {
  776. new range;
  777. if(sscanf(params, "d", range)) {
  778. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /audiourl [range].");
  779. return 1;
  780. }
  781. SetPVarInt(playerid, "aURLrange", range);
  782. ShowPlayerDialogEx(playerid, AUDIO_URL, DIALOG_STYLE_INPUT, "Audio URL", "Enter Audio URL", "OK", "Cancel");
  783. }
  784. else {
  785. SendClientMessageEx(playerid, COLOR_GRAD1, " You are not authorized to use that command !");
  786. return 1;
  787. }
  788. return 1;
  789. }
  790. CMD:fixr(playerid, params[])
  791. {
  792. PlayerFixRadio(playerid);
  793. return 1;
  794. }
  795. CMD:music(playerid, params[])
  796. {
  797. if(PlayerInfo[playerid][pCDPlayer])
  798. {
  799. new choice[32];
  800. if(sscanf(params, "s[32]", choice))
  801. {
  802. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /music [name]");
  803. SendClientMessageEx(playerid, COLOR_GREY, "Available names: On, Off, Next");
  804. return 1;
  805. }
  806. if(strcmp(choice,"on",true) == 0)
  807. {
  808. GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~g~Music person On", 5000, 5);
  809. new channel = Music[playerid];
  810. PlayerPlaySound(playerid, Songs[channel][0], 0.0, 0.0, 0.0);
  811. }
  812. else if(strcmp(choice,"off",true) == 0)
  813. {
  814. GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~r~Music person Off", 5000, 5);
  815. PlayerFixRadio(playerid);
  816. if(GetPVarType(playerid, "MusicIRadio"))
  817. {
  818. StopAudioStreamForPlayerEx(playerid);
  819. DeletePVar(playerid, "MusicIRadio");
  820. }
  821. }
  822. else if(strcmp(choice,"next",true) == 0)
  823. {
  824. if(Music[playerid] == 0) { Music[playerid] = 1; }
  825. else if(Music[playerid] == 1) { Music[playerid] = 2; }
  826. else if(Music[playerid] == 2) { Music[playerid] = 3; }
  827. else if(Music[playerid] == 3) { Music[playerid] = 4; }
  828. else if(Music[playerid] == 4) { Music[playerid] = 5; }
  829. else if(Music[playerid] == 5) { Music[playerid] = 6; }
  830. else if(Music[playerid] == 6) { Music[playerid] = 0; }
  831. new channel = Music[playerid];
  832. PlayerPlaySound(playerid, Songs[channel][0], 0.0, 0.0, 0.0);
  833. }
  834. else
  835. {
  836. SendClientMessageEx(playerid, COLOR_GREY, " Unknown music command!");
  837. return 1;
  838. }
  839. }
  840. else
  841. {
  842. SendClientMessageEx(playerid, COLOR_GREY, " You don't have a Music-Player!");
  843. return 1;
  844. }
  845. return 1;
  846. }
  847. CMD:mp3(playerid, params[])
  848. {
  849. if(PlayerInfo[playerid][pCDPlayer] || PlayerInfo[playerid][pAdmin] >= 2)
  850. {
  851. if(IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_GRAD2, "You must be on foot to use your MP3 Player.");
  852. ShowSetStation(playerid, "MP3 Player - Choose a station");
  853. }
  854. else return SendClientMessageEx(playerid, COLOR_GRAD2, "You do not have a CD Player/MP3 Player.");
  855. return 1;
  856. }