04.09.2013, 10:20
pawn Код:
#define AUDIO_DIALOG 2065 //Surely this will not conflict with other dialogs in your gamemode/filterscripts. If it does, change it.
CMD:audiourl(playerid, params[])
{
//if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "Only an RCON Administrator can use this command."); //Recommended that you add a line similar to this
ShowPlayerDialog(playerid, AUDIO_DIALOG, DIALOG_STYLE_INPUT, "Audio Source", "Enter the URL of the Audio Source here:", "Play", "Cancel");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == AUDIO_DIALOG)
{
if(response)
{
//Additionally, you can add checks here to ensure that the url that has been entered is a valid source of audio.
//Example: Ending in .mp3, .mp4, etc.
SendClientMessageToAll(0xFFFF00FF, "An Administrator has started playing audio for all players.");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
StopAudioStreamForPlayer(i);
PlayAudioStreamForPlayer(i, inputtext);
}
}
}
}
return 1;
}