Guest User

Djpanel

a guest
Apr 16th, 2015
493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.50 KB | None | 0 0
  1. enum infoTrack
  2. {
  3. TrackName[500],
  4. TrackURL[500]
  5. }
  6. new PlayList[20][infoTrack];
  7. new TrackOnly;
  8. new PlayerText:TrackListLeft[21]= {PlayerText:-1, ...};
  9. new Text:PlayListUSEbox[8];
  10. new Text:DJpanelText;
  11. new Float:TrackListUSEboxX[8] = {226.000000,622.000000,224.399993,630.799987,504.400024,417.200012,324.400024,618.000000};
  12. new Float:TrackListUSEboxY[8] = {135.153335,135.153335,135.900009,397.979980,398.726654,399.473327,399.473327,135.153335};
  13. new Float:TrackListBoxSize[2][8] =
  14. {
  15. {27.061113,27.144075,1.591480,2.338148,2.172224,2.089261,2.338148,1.757408},
  16. {18.000000,402.000000,20.399999,566.000000,553.200012,486.800018,390.000000,404.399993}
  17. };
  18. new JanrName[2][30] = { "DubStep","Exit"};
  19. new Text:TrackListJanr[2];
  20. new Float:TrackJanrX[4] = {331.999938,436.800109,504.799926,587.200134};
  21. new Float:TrackJanrTextsize[4] = {375.999908,470.399963,553.599914,614.400085};
  22. new Djcords;
  23. new bool:FixDJCords[MAX_PLAYERS];
  24. public OnGameModeInit()
  25. {
  26. for(new x; x<sizeof(PlayListUSEbox); x++)
  27. {
  28. PlayListUSEbox[x] = TextDrawCreate(TrackListUSEboxX[x], TrackListUSEboxY[x], "usebox");
  29. TextDrawLetterSize(PlayListUSEbox[x], 0.000000, TrackListBoxSize[0][x]);
  30. TextDrawTextSize(PlayListUSEbox[x], TrackListBoxSize[1][x], 0.000000);
  31. TextDrawAlignment(PlayListUSEbox[x], 1);
  32. TextDrawColor(PlayListUSEbox[x], 0);
  33. TextDrawUseBox(PlayListUSEbox[x], true);
  34. TextDrawBoxColor(PlayListUSEbox[x], 102);
  35. TextDrawSetShadow(PlayListUSEbox[x], 0);
  36. TextDrawSetOutline(PlayListUSEbox[x], 0);
  37. TextDrawFont(PlayListUSEbox[x], 0);
  38. }
  39. for(new y; y<sizeof(TrackListJanr); y++)
  40. {
  41. TrackListJanr[y] = TextDrawCreate(TrackJanrX[y], 399.466583, JanrName[y]);
  42. TextDrawLetterSize(TrackListJanr[y], 0.466000, 2.010667);
  43. TextDrawTextSize(TrackListJanr[y], TrackJanrTextsize[y], 18.666667);
  44. TextDrawAlignment(TrackListJanr[y], 1);
  45. TextDrawColor(TrackListJanr[y], -1);
  46. TextDrawSetShadow(TrackListJanr[y], 0);
  47. TextDrawSetOutline(TrackListJanr[y], 1);
  48. TextDrawBackgroundColor(TrackListJanr[y], 51);
  49. TextDrawFont(TrackListJanr[y], 1);
  50. TextDrawSetProportional(TrackListJanr[y], 1);
  51. TextDrawSetSelectable(TrackListJanr[y], 1);
  52. }
  53. DJpanelText = TextDrawCreate(68.800018, 132.906616, "Dj Panel");
  54. TextDrawLetterSize(DJpanelText, 0.625200, 1.883733);
  55. TextDrawAlignment(DJpanelText, 1);
  56. TextDrawColor(DJpanelText, -1);
  57. TextDrawSetShadow(DJpanelText, 0);
  58. TextDrawSetOutline(DJpanelText, 1);
  59. TextDrawBackgroundColor(DJpanelText, 51);
  60. TextDrawFont(DJpanelText, 1);
  61. TextDrawSetProportional(DJpanelText, 1);
  62. Create3DTextLabel("-=DJ Panel=-",COLOR_GREEN,x,y,z,25.0,0,1); //Coordinates replace its
  63. Djcords = CreateDynamicSphere(x,y,z,2.0,0,0); //Coordinates replace its
  64. LoadPlayList();
  65. return true;
  66. }
  67. public OnPlayerConnect(playerid)
  68. {
  69. for(new i; i<10; i++)
  70. {
  71. TrackListLeft[i] = CreatePlayerTextDraw(playerid,21.600006, 160.533294+i*20, "Track");
  72. PlayerTextDrawLetterSize(playerid,TrackListLeft[i], 0.449999, 1.600000);
  73. PlayerTextDrawTextSize(playerid, TrackListLeft[i], 219.200057, 18.426670);
  74. PlayerTextDrawAlignment(playerid,TrackListLeft[i], 1);
  75. PlayerTextDrawColor(playerid,TrackListLeft[i], -1);
  76. PlayerTextDrawSetShadow(playerid,TrackListLeft[i], 0);
  77. PlayerTextDrawSetOutline(playerid,TrackListLeft[i], 1);
  78. PlayerTextDrawBackgroundColor(playerid,TrackListLeft[i], 51);
  79. PlayerTextDrawFont(playerid,TrackListLeft[i], 1);
  80. PlayerTextDrawSetOutline(playerid,TrackListLeft[i], 0);
  81. PlayerTextDrawSetProportional(playerid,TrackListLeft[i], 1);
  82. PlayerTextDrawSetSelectable(playerid,TrackListLeft[i], 1);
  83. }
  84. for(new i = 10; i<20; i++)
  85. {
  86. //format(coordsstrings, 16, "Track (%d)", i+1);
  87. TrackListLeft[i] = CreatePlayerTextDraw(playerid,406.400146, 159.039978+(i-10)*20, "Track");
  88. PlayerTextDrawLetterSize(playerid,TrackListLeft[i], 0.449999, 1.600000);
  89. PlayerTextDrawTextSize(playerid, TrackListLeft[i], 616.000000, 18.933330);
  90. PlayerTextDrawAlignment(playerid,TrackListLeft[i], 1);
  91. PlayerTextDrawColor(playerid,TrackListLeft[i], -1);
  92. PlayerTextDrawSetShadow(playerid,TrackListLeft[i], 0);
  93. PlayerTextDrawSetOutline(playerid,TrackListLeft[i], 1);
  94. PlayerTextDrawBackgroundColor(playerid,TrackListLeft[i], 51);
  95. PlayerTextDrawFont(playerid,TrackListLeft[i], 1);
  96. PlayerTextDrawSetProportional(playerid,TrackListLeft[i], 1);
  97. PlayerTextDrawSetSelectable(playerid,TrackListLeft[i], 1);
  98. }
  99. return true;
  100. }
  101. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
  102. {
  103. new string[65];
  104. if(FixDJCords[playerid])
  105. {
  106. if(_:playertextid == 65535) SelectTextDraw(playerid, 0xAFAFAFFF);
  107. for(new i; i<sizeof(TrackListLeft); i++)
  108. {
  109. if(playertextid == TrackListLeft[i])
  110. {
  111. format(string, sizeof(string),"Playing music %s",PlayList[i][TrackName]);
  112. SendClientMessage(playerid,-1,string);
  113. new x = GetMaxPlayers();
  114. do
  115. {
  116. --x;
  117. PlayAudioStreamForPlayer(x, PlayList[i][TrackURL], x,y,z, 55); //Coordinates replace its
  118. }
  119. while(x);
  120. }
  121. }
  122. }
  123. return true;
  124. }
  125. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  126. {
  127. if(FixDJCords[playerid])
  128. {
  129. if(_:clickedid == 65535) SelectTextDraw(playerid, 0xAFAFAFFF);
  130. else if(clickedid == TrackListJanr[0])
  131. {
  132. ShowPlayList(playerid);
  133. }
  134. else if(clickedid == TrackListJanr[1])
  135. {
  136. CancelSelectTextDraw(playerid);
  137. for(new x; x<sizeof(PlayListUSEbox); x++) TextDrawHideForPlayer(playerid, PlayListUSEbox[x]);
  138. for(new y; y<sizeof(TrackListJanr); y++) TextDrawHideForPlayer(playerid, TrackListJanr[y]);
  139. TextDrawHideForPlayer(playerid, DJpanelText);
  140. FixDJCords[playerid] = false;
  141. for(new i = 0; i < 22; i++) PlayerTextDrawHide(playerid, TrackListLeft[i]);
  142. }
  143. }
  144. return true;
  145. }
  146. CMD:newtrack(playerid, params[])
  147. {
  148. strcat(cstring,"{33AAFF}Enter a name for the new Music and Address (URL) separated by commas\n");
  149. strcat(cstring,"{33AAFF}Example:{83D02A}\tTrancOnLy,http://melody.uz:8003/europa\n");
  150. ShowPlayerDialog(playerid, 4879, 1, "New Music", cstring, "Create", "Cansel");
  151. return true;
  152. }
  153. CMD:tracklist(playerid, params[])
  154. {
  155. new str[42], strs[128];
  156. for(new f; f < sizeof(PlayList); f++)
  157. {
  158. format(str, sizeof(str), "[%d]%s\n", f+1, PlayList[f][TrackName],PlayList[f][TrackURL]);
  159. strcat(strs,str);
  160. }
  161. ShowPlayerDialog(playerid, 9942, DIALOG_STYLE_LIST, "Editing of Music and Address (URL)", strs, "Select", "Cancel");
  162. return true;
  163. }
  164. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  165. {
  166. case 4879:
  167. {
  168. if(response)
  169. {
  170. if(!strlen(inputtext))
  171. {
  172. strcat(string,"{33AAFF}Enter a name for the new Music and Address (URL) separated by commas\n");
  173. strcat(string,"{33AAFF}Example:{83D02A}\tTrancOnLy,http://melody.uz:8003/europa\n");
  174. ShowPlayerDialog(playerid, 4879, 1, "New Music", string, "Create", "Cancel");
  175. }
  176. if(strfind(inputtext,"http://",true) != -1 && strfind(inputtext,".uz",true) != -1)
  177. {
  178. new namemusic[128], nameurl[128];
  179. sscanf(inputtext, "p<,>s[128]s[128]", namemusic, nameurl);
  180. SetString(PlayList[TrackOnly][TrackURL], nameurl);
  181. SetString(PlayList[TrackOnly][TrackName], namemusic);
  182. format(string,sizeof(string),"Music '%s URL:%s' successfully created", namemusic,nameurl);
  183. SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  184. SavePlayList();
  185. }
  186. }
  187. }
  188. case 9942:
  189. {
  190. if(response)
  191. {
  192. strcat(string,"{33AAFF}Do you want to edit music %s\n",PlayList[listitem][TrackName]);
  193. strcat(string,"{33AAFF}Enter a name for the new Music and Address (URL) separated by commas\n");
  194. strcat(string,"{33AAFF}Example:{83D02A}\tTrancOnLy,http://melody.uz:8003/europa\n");
  195. ShowPlayerDialog(playerid, 4880, 1, "Name music", string, "Create", "Cancel");
  196. RedakMuz[playerid] = listitem;
  197. return true;
  198. }
  199. return true;
  200. }
  201. case 4880:
  202. {
  203. if(response)
  204. {
  205. new count = RedakMuz[playerid];
  206. if(!strlen(inputtext))
  207. {
  208. strcat(string,"{33AAFF}Do you want to edit music %s\n",PlayList[count][TrackName]);
  209. strcat(string,"{33AAFF}Enter a name for the new Music and Address (URL) separated by commas\n");
  210. strcat(string,"{33AAFF}Example:{83D02A}\tTrancOnLy,http://melody.uz:8003/europa\n");
  211. ShowPlayerDialog(playerid, 4880, 1, "Name music", string, "Create", "Cancel");
  212. }
  213. if(strfind(inputtext,"http://",true) != -1 && strfind(inputtext,".uz",true) != -1)
  214. {
  215. new namemusic[128], nameurl[128];
  216. sscanf(inputtext, "p<,>s[128]s[128]", namemusic, nameurl);
  217. SetString(PlayList[count][TrackURL], nameurl);
  218. SetString(PlayList[count][TrackName], namemusic);
  219. format(string,sizeof(string),"Music '%s URL:%s' successfully created", namemusic,nameurl);
  220. SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  221. RedakMuz[playerid] = -1;
  222. SavePlayList();
  223. }
  224. }
  225. }
  226. return 1;
  227. }
  228. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  229. {
  230. if(newkeys == 512) //Click on the scroll mouse
  231. {
  232. if(FixDJCords[playerid])
  233. {
  234. SelectTextDraw(playerid, COLOR_LIGHTBLUE);
  235. }
  236. }
  237. return true;
  238. }
  239. public OnPlayerLeaveDynamicArea(playerid, areaid)
  240. {
  241. else if(areaid == Djcords)
  242. {
  243. for(new x; x<sizeof(PlayListUSEbox); x++) TextDrawHideForPlayer(playerid, PlayListUSEbox[x]);
  244. for(new y; y<sizeof(TrackListJanr); y++) TextDrawHideForPlayer(playerid, TrackListJanr[y]);
  245. TextDrawHideForPlayer(playerid, DJpanelText);
  246. FixDJCords[playerid] = false;
  247. }
  248. return true;
  249. }
  250. public OnPlayerEnterDynamicArea(playerid, areaid)
  251. {
  252. else if(areaid == Djcords)
  253. {
  254. for(new x; x<sizeof(PlayListUSEbox); x++) TextDrawShowForPlayer(playerid, PlayListUSEbox[x]);
  255. for(new y; y<sizeof(TrackListJanr); y++) TextDrawShowForPlayer(playerid, TrackListJanr[y]);
  256. TextDrawShowForPlayer(playerid, DJpanelText);
  257. FixDJCords[playerid] = true;
  258. }
  259. return true;
  260. }
  261. stock LoadPlayList()
  262. {
  263. new arrCoords[3][100];
  264. new strFromFile2[256];
  265. new File: file = fopen("[PlayList]/PlayerLists.ini", io_read);
  266. if (file)
  267. {
  268. new idx;
  269. while (idx < sizeof(PlayList))
  270. {
  271. fread(file, strFromFile2);
  272. split(strFromFile2, arrCoords, '|');
  273. strmid(PlayList[idx][TrackName], arrCoords[0], 0, strlen(arrCoords[0]), 255);
  274. strmid(PlayList[idx][TrackURL], arrCoords[1], 0, strlen(arrCoords[1]), 255);
  275. idx++;
  276. }
  277. fclose(file);
  278. printf("[ Loading ... ] %d PlayList successfully loaded.",idx,TrackOnly);
  279. }
  280. else
  281. {
  282. for (new i = 0; i < sizeof(PlayList); i ++)
  283. {
  284. SetString(PlayList[i][TrackName],"No_Music_Name");
  285. SetString(PlayList[i][TrackURL],"No_Music_URL");
  286. }
  287. SavePlayList();
  288. }
  289. return 1;
  290. }
  291. stock SavePlayList()
  292. {
  293. new File: file;
  294. for (new i = 0;i < sizeof(PlayList);i ++)
  295. {
  296. new string[100], str[50];
  297. format(string, sizeof(string), "%s|%s|\n",
  298. PlayList[i][TrackName],
  299. PlayList[i][TrackURL]);
  300. format(str, sizeof(str),"[PlayList]/PlayerLists.ini");
  301. if(!i) file = fopen(str, io_write);
  302. else file = fopen(str, io_append);
  303. fwrite(file, string);
  304. fclose(file);
  305. }
  306. return true;
  307. }
  308. stock ShowPlayList(playerid)
  309. {
  310. new str[128];
  311. for(new i; i < sizeof(PlayList); i ++)
  312. {
  313. if(!GetString(PlayList[i][TrackName],"No_Music_Name"))
  314. {
  315. format(str,sizeof(str),"%s (%d)\n",PlayList[i][TrackName],i+1);
  316. PlayerTextDrawSetString(playerid,TrackListLeft[i], str);
  317. PlayerTextDrawShow(playerid,TrackListLeft[i]);
  318. TrackOnly++;
  319. }
  320. }
  321. return true;
  322. }
  323. stock GetString(param1[],param2[])
  324. {
  325. return !strcmp(param1, param2, false);
  326. }
  327. stock SetString(param_1[],param_2[])
  328. {
  329. return strmid(param_1,param_2,0,strlen(param_2),255);
  330. }
Advertisement
Add Comment
Please, Sign In to add comment