Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum infoTrack
- {
- TrackName[500],
- TrackURL[500]
- }
- new PlayList[20][infoTrack];
- new TrackOnly;
- new PlayerText:TrackListLeft[21]= {PlayerText:-1, ...};
- new Text:PlayListUSEbox[8];
- new Text:DJpanelText;
- new Float:TrackListUSEboxX[8] = {226.000000,622.000000,224.399993,630.799987,504.400024,417.200012,324.400024,618.000000};
- new Float:TrackListUSEboxY[8] = {135.153335,135.153335,135.900009,397.979980,398.726654,399.473327,399.473327,135.153335};
- new Float:TrackListBoxSize[2][8] =
- {
- {27.061113,27.144075,1.591480,2.338148,2.172224,2.089261,2.338148,1.757408},
- {18.000000,402.000000,20.399999,566.000000,553.200012,486.800018,390.000000,404.399993}
- };
- new JanrName[2][30] = { "DubStep","Exit"};
- new Text:TrackListJanr[2];
- new Float:TrackJanrX[4] = {331.999938,436.800109,504.799926,587.200134};
- new Float:TrackJanrTextsize[4] = {375.999908,470.399963,553.599914,614.400085};
- new Djcords;
- new bool:FixDJCords[MAX_PLAYERS];
- public OnGameModeInit()
- {
- for(new x; x<sizeof(PlayListUSEbox); x++)
- {
- PlayListUSEbox[x] = TextDrawCreate(TrackListUSEboxX[x], TrackListUSEboxY[x], "usebox");
- TextDrawLetterSize(PlayListUSEbox[x], 0.000000, TrackListBoxSize[0][x]);
- TextDrawTextSize(PlayListUSEbox[x], TrackListBoxSize[1][x], 0.000000);
- TextDrawAlignment(PlayListUSEbox[x], 1);
- TextDrawColor(PlayListUSEbox[x], 0);
- TextDrawUseBox(PlayListUSEbox[x], true);
- TextDrawBoxColor(PlayListUSEbox[x], 102);
- TextDrawSetShadow(PlayListUSEbox[x], 0);
- TextDrawSetOutline(PlayListUSEbox[x], 0);
- TextDrawFont(PlayListUSEbox[x], 0);
- }
- for(new y; y<sizeof(TrackListJanr); y++)
- {
- TrackListJanr[y] = TextDrawCreate(TrackJanrX[y], 399.466583, JanrName[y]);
- TextDrawLetterSize(TrackListJanr[y], 0.466000, 2.010667);
- TextDrawTextSize(TrackListJanr[y], TrackJanrTextsize[y], 18.666667);
- TextDrawAlignment(TrackListJanr[y], 1);
- TextDrawColor(TrackListJanr[y], -1);
- TextDrawSetShadow(TrackListJanr[y], 0);
- TextDrawSetOutline(TrackListJanr[y], 1);
- TextDrawBackgroundColor(TrackListJanr[y], 51);
- TextDrawFont(TrackListJanr[y], 1);
- TextDrawSetProportional(TrackListJanr[y], 1);
- TextDrawSetSelectable(TrackListJanr[y], 1);
- }
- DJpanelText = TextDrawCreate(68.800018, 132.906616, "Dj Panel");
- TextDrawLetterSize(DJpanelText, 0.625200, 1.883733);
- TextDrawAlignment(DJpanelText, 1);
- TextDrawColor(DJpanelText, -1);
- TextDrawSetShadow(DJpanelText, 0);
- TextDrawSetOutline(DJpanelText, 1);
- TextDrawBackgroundColor(DJpanelText, 51);
- TextDrawFont(DJpanelText, 1);
- TextDrawSetProportional(DJpanelText, 1);
- Create3DTextLabel("-=DJ Panel=-",COLOR_GREEN,x,y,z,25.0,0,1); //Coordinates replace its
- Djcords = CreateDynamicSphere(x,y,z,2.0,0,0); //Coordinates replace its
- LoadPlayList();
- return true;
- }
- public OnPlayerConnect(playerid)
- {
- for(new i; i<10; i++)
- {
- TrackListLeft[i] = CreatePlayerTextDraw(playerid,21.600006, 160.533294+i*20, "Track");
- PlayerTextDrawLetterSize(playerid,TrackListLeft[i], 0.449999, 1.600000);
- PlayerTextDrawTextSize(playerid, TrackListLeft[i], 219.200057, 18.426670);
- PlayerTextDrawAlignment(playerid,TrackListLeft[i], 1);
- PlayerTextDrawColor(playerid,TrackListLeft[i], -1);
- PlayerTextDrawSetShadow(playerid,TrackListLeft[i], 0);
- PlayerTextDrawSetOutline(playerid,TrackListLeft[i], 1);
- PlayerTextDrawBackgroundColor(playerid,TrackListLeft[i], 51);
- PlayerTextDrawFont(playerid,TrackListLeft[i], 1);
- PlayerTextDrawSetOutline(playerid,TrackListLeft[i], 0);
- PlayerTextDrawSetProportional(playerid,TrackListLeft[i], 1);
- PlayerTextDrawSetSelectable(playerid,TrackListLeft[i], 1);
- }
- for(new i = 10; i<20; i++)
- {
- //format(coordsstrings, 16, "Track (%d)", i+1);
- TrackListLeft[i] = CreatePlayerTextDraw(playerid,406.400146, 159.039978+(i-10)*20, "Track");
- PlayerTextDrawLetterSize(playerid,TrackListLeft[i], 0.449999, 1.600000);
- PlayerTextDrawTextSize(playerid, TrackListLeft[i], 616.000000, 18.933330);
- PlayerTextDrawAlignment(playerid,TrackListLeft[i], 1);
- PlayerTextDrawColor(playerid,TrackListLeft[i], -1);
- PlayerTextDrawSetShadow(playerid,TrackListLeft[i], 0);
- PlayerTextDrawSetOutline(playerid,TrackListLeft[i], 1);
- PlayerTextDrawBackgroundColor(playerid,TrackListLeft[i], 51);
- PlayerTextDrawFont(playerid,TrackListLeft[i], 1);
- PlayerTextDrawSetProportional(playerid,TrackListLeft[i], 1);
- PlayerTextDrawSetSelectable(playerid,TrackListLeft[i], 1);
- }
- return true;
- }
- public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
- {
- new string[65];
- if(FixDJCords[playerid])
- {
- if(_:playertextid == 65535) SelectTextDraw(playerid, 0xAFAFAFFF);
- for(new i; i<sizeof(TrackListLeft); i++)
- {
- if(playertextid == TrackListLeft[i])
- {
- format(string, sizeof(string),"Playing music %s",PlayList[i][TrackName]);
- SendClientMessage(playerid,-1,string);
- new x = GetMaxPlayers();
- do
- {
- --x;
- PlayAudioStreamForPlayer(x, PlayList[i][TrackURL], x,y,z, 55); //Coordinates replace its
- }
- while(x);
- }
- }
- }
- return true;
- }
- public OnPlayerClickTextDraw(playerid, Text:clickedid)
- {
- if(FixDJCords[playerid])
- {
- if(_:clickedid == 65535) SelectTextDraw(playerid, 0xAFAFAFFF);
- else if(clickedid == TrackListJanr[0])
- {
- ShowPlayList(playerid);
- }
- else if(clickedid == TrackListJanr[1])
- {
- CancelSelectTextDraw(playerid);
- for(new x; x<sizeof(PlayListUSEbox); x++) TextDrawHideForPlayer(playerid, PlayListUSEbox[x]);
- for(new y; y<sizeof(TrackListJanr); y++) TextDrawHideForPlayer(playerid, TrackListJanr[y]);
- TextDrawHideForPlayer(playerid, DJpanelText);
- FixDJCords[playerid] = false;
- for(new i = 0; i < 22; i++) PlayerTextDrawHide(playerid, TrackListLeft[i]);
- }
- }
- return true;
- }
- CMD:newtrack(playerid, params[])
- {
- strcat(cstring,"{33AAFF}Enter a name for the new Music and Address (URL) separated by commas\n");
- strcat(cstring,"{33AAFF}Example:{83D02A}\tTrancOnLy,http://melody.uz:8003/europa\n");
- ShowPlayerDialog(playerid, 4879, 1, "New Music", cstring, "Create", "Cansel");
- return true;
- }
- CMD:tracklist(playerid, params[])
- {
- new str[42], strs[128];
- for(new f; f < sizeof(PlayList); f++)
- {
- format(str, sizeof(str), "[%d]%s\n", f+1, PlayList[f][TrackName],PlayList[f][TrackURL]);
- strcat(strs,str);
- }
- ShowPlayerDialog(playerid, 9942, DIALOG_STYLE_LIST, "Editing of Music and Address (URL)", strs, "Select", "Cancel");
- return true;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- case 4879:
- {
- if(response)
- {
- if(!strlen(inputtext))
- {
- strcat(string,"{33AAFF}Enter a name for the new Music and Address (URL) separated by commas\n");
- strcat(string,"{33AAFF}Example:{83D02A}\tTrancOnLy,http://melody.uz:8003/europa\n");
- ShowPlayerDialog(playerid, 4879, 1, "New Music", string, "Create", "Cancel");
- }
- if(strfind(inputtext,"http://",true) != -1 && strfind(inputtext,".uz",true) != -1)
- {
- new namemusic[128], nameurl[128];
- sscanf(inputtext, "p<,>s[128]s[128]", namemusic, nameurl);
- SetString(PlayList[TrackOnly][TrackURL], nameurl);
- SetString(PlayList[TrackOnly][TrackName], namemusic);
- format(string,sizeof(string),"Music '%s URL:%s' successfully created", namemusic,nameurl);
- SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
- SavePlayList();
- }
- }
- }
- case 9942:
- {
- if(response)
- {
- strcat(string,"{33AAFF}Do you want to edit music %s\n",PlayList[listitem][TrackName]);
- strcat(string,"{33AAFF}Enter a name for the new Music and Address (URL) separated by commas\n");
- strcat(string,"{33AAFF}Example:{83D02A}\tTrancOnLy,http://melody.uz:8003/europa\n");
- ShowPlayerDialog(playerid, 4880, 1, "Name music", string, "Create", "Cancel");
- RedakMuz[playerid] = listitem;
- return true;
- }
- return true;
- }
- case 4880:
- {
- if(response)
- {
- new count = RedakMuz[playerid];
- if(!strlen(inputtext))
- {
- strcat(string,"{33AAFF}Do you want to edit music %s\n",PlayList[count][TrackName]);
- strcat(string,"{33AAFF}Enter a name for the new Music and Address (URL) separated by commas\n");
- strcat(string,"{33AAFF}Example:{83D02A}\tTrancOnLy,http://melody.uz:8003/europa\n");
- ShowPlayerDialog(playerid, 4880, 1, "Name music", string, "Create", "Cancel");
- }
- if(strfind(inputtext,"http://",true) != -1 && strfind(inputtext,".uz",true) != -1)
- {
- new namemusic[128], nameurl[128];
- sscanf(inputtext, "p<,>s[128]s[128]", namemusic, nameurl);
- SetString(PlayList[count][TrackURL], nameurl);
- SetString(PlayList[count][TrackName], namemusic);
- format(string,sizeof(string),"Music '%s URL:%s' successfully created", namemusic,nameurl);
- SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
- RedakMuz[playerid] = -1;
- SavePlayList();
- }
- }
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys == 512) //Click on the scroll mouse
- {
- if(FixDJCords[playerid])
- {
- SelectTextDraw(playerid, COLOR_LIGHTBLUE);
- }
- }
- return true;
- }
- public OnPlayerLeaveDynamicArea(playerid, areaid)
- {
- else if(areaid == Djcords)
- {
- for(new x; x<sizeof(PlayListUSEbox); x++) TextDrawHideForPlayer(playerid, PlayListUSEbox[x]);
- for(new y; y<sizeof(TrackListJanr); y++) TextDrawHideForPlayer(playerid, TrackListJanr[y]);
- TextDrawHideForPlayer(playerid, DJpanelText);
- FixDJCords[playerid] = false;
- }
- return true;
- }
- public OnPlayerEnterDynamicArea(playerid, areaid)
- {
- else if(areaid == Djcords)
- {
- for(new x; x<sizeof(PlayListUSEbox); x++) TextDrawShowForPlayer(playerid, PlayListUSEbox[x]);
- for(new y; y<sizeof(TrackListJanr); y++) TextDrawShowForPlayer(playerid, TrackListJanr[y]);
- TextDrawShowForPlayer(playerid, DJpanelText);
- FixDJCords[playerid] = true;
- }
- return true;
- }
- stock LoadPlayList()
- {
- new arrCoords[3][100];
- new strFromFile2[256];
- new File: file = fopen("[PlayList]/PlayerLists.ini", io_read);
- if (file)
- {
- new idx;
- while (idx < sizeof(PlayList))
- {
- fread(file, strFromFile2);
- split(strFromFile2, arrCoords, '|');
- strmid(PlayList[idx][TrackName], arrCoords[0], 0, strlen(arrCoords[0]), 255);
- strmid(PlayList[idx][TrackURL], arrCoords[1], 0, strlen(arrCoords[1]), 255);
- idx++;
- }
- fclose(file);
- printf("[ Loading ... ] %d PlayList successfully loaded.",idx,TrackOnly);
- }
- else
- {
- for (new i = 0; i < sizeof(PlayList); i ++)
- {
- SetString(PlayList[i][TrackName],"No_Music_Name");
- SetString(PlayList[i][TrackURL],"No_Music_URL");
- }
- SavePlayList();
- }
- return 1;
- }
- stock SavePlayList()
- {
- new File: file;
- for (new i = 0;i < sizeof(PlayList);i ++)
- {
- new string[100], str[50];
- format(string, sizeof(string), "%s|%s|\n",
- PlayList[i][TrackName],
- PlayList[i][TrackURL]);
- format(str, sizeof(str),"[PlayList]/PlayerLists.ini");
- if(!i) file = fopen(str, io_write);
- else file = fopen(str, io_append);
- fwrite(file, string);
- fclose(file);
- }
- return true;
- }
- stock ShowPlayList(playerid)
- {
- new str[128];
- for(new i; i < sizeof(PlayList); i ++)
- {
- if(!GetString(PlayList[i][TrackName],"No_Music_Name"))
- {
- format(str,sizeof(str),"%s (%d)\n",PlayList[i][TrackName],i+1);
- PlayerTextDrawSetString(playerid,TrackListLeft[i], str);
- PlayerTextDrawShow(playerid,TrackListLeft[i]);
- TrackOnly++;
- }
- }
- return true;
- }
- stock GetString(param1[],param2[])
- {
- return !strcmp(param1, param2, false);
- }
- stock SetString(param_1[],param_2[])
- {
- return strmid(param_1,param_2,0,strlen(param_2),255);
- }
Advertisement
Add Comment
Please, Sign In to add comment