28.08.2013, 03:37
pawn Код:
COMMAND:addmusic(playerid,params[])
{
new name[50],link[70],pname[MAX_PLAYER_NAME],fstring[256];
if(sscanf(params,"s[50]s[70]",name,link)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: /addmusic [Name] [Link");
GetPlayerName(playerid,pname,sizeof(pname));
indexsong[playerid] = GetPlayerMusicCount(playerid);
format(fstring,sizeof(fstring),"/Songs/%s/%d.music",pname,indexsong[playerid]);
dini_Create(fstring);
dini_Set(fstring,"Name",name);
dini_Set(fstring,"Link",link);
SendClientMessage(playerid,COLOR_GREEN,"Added to your mp3. Use /mp3 to hear it");
return 1;
}
COMMAND:mp3(playerid,params[])
{
new pname[50],mstring[2000],str1[256],str2[260],file[100];
GetPlayerName(playerid,pname,sizeof(pname));
for(new i = 0; i <= MAX_SONGS; i++)
{
format(file,sizeof(file),"/Songs/%s/%d.music",pname,i);
if(dini_Exists(file))
{
str1 = dini_Get(file,"Name");
format(str2,sizeof(str2),"%s\n",str1);
strcat(mstring,str2);
}
}
ShowPlayerDialog(playerid,DIALOG_MUSIC,DIALOG_STYLE_LIST,"Song List",mstring,"Hear","Cancel");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_MUSIC)
{
if(response)
{
new pname[50],file[200],link[256],send[128],name[256];
GetPlayerName(playerid,pname,sizeof(pname));
format(file,sizeof(file),"/Songs/%s/%d.music",pname,listitem);
link = dini_Get(file,"Link");
name = dini_Get(file,"Name");
PlayAudioStreamForPlayer(playerid,link);
format(send,sizeof(send),"You have play song name %s",name);
SendClientMessage(playerid,COLOR_GREEN,send);
}
}
return 1;
}
stock GetPlayerMusicCount(playerid)
{
new file[100],pname[50];
GetPlayerName(playerid,pname,sizeof(pname));
for(new i = 0; i <= MAX_SONGS; i++)
{
format(file,sizeof(file),"/Songs/%s/%d.music",pname,i);
if(!dini_Exists(file))
{
return i;
}
}
return 1;
}