[Tutorial] Making a music command.
#10

Quote:
Originally Posted by TheFlyer
Посмотреть сообщение
pawn Код:
CMD:burn(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1) return 0;
for(new i=0; i<MAX_PLAYERS; i++)
{
PlayAudioStreamForPlayer(i,"http://dl.farskids405.com/Aria/92/4/15/Ellie%20Goulding%20-%20Burn%20[128]. mp3");
SendClientMessageToAll(COLOR_GREEN,"Track playing-Ellie Goulding - Burn");        
return 1;
}
return 1;
}
Would it show only 1 time if we put "return 1;" under sendclientmessage?
Nope, because you're breaking the loop after playerid 0 has been processed.
All players will see the message, but only player 0 will hear it.

pawn Код:
command(burn, playerid, params[]) //This is how the ZCMD processor is used, this is creating the command so it can be used and perform the required code.
{
    for(new i=0; i<MAX_PLAYERS; i++) //This will create a loop to see who is connected to the server.
    {
        if(IsPlayerConnected(i)) //This will check the loop to see if the player(s) are connected, and if so they will be selected and the music file will be played out to them.
        {
            PlayAudioStreamForPlayer(i,"http://dl.farskids405.com/Aria/92/4/15/Ellie%20Goulding%20-%20Burn%20[128].mp3"); //This function will grab the mp3 file from the URL, then play it back to the connected players.
        }
    }
    SendClientMessageToAll(-1, "Track playing-Ellie Goulding - Burn"); //This will send a message to all connected players, notifying them that "Ellie Goulding - Burn" is playing.

    return 1;
}

Just put the message outside the loop.
Reply


Messages In This Thread
Making a music command. - by jdog105 - 02.11.2013, 18:44
Re: Making a music command. - by bensmart469 - 02.11.2013, 21:32
Re: Making a music command. - by Albright - 03.11.2013, 08:03
Re: Making a music command. - by LeeXian99 - 03.11.2013, 09:56
Re: Making a music command. - by iGetty - 04.11.2013, 03:57
AW: Making a music command. - by Skimmer - 04.11.2013, 14:50
Re: AW: Making a music command. - by jdog105 - 05.02.2014, 20:51
Re: Making a music command. - by BullseyeHawk - 05.02.2014, 21:18
Re: Making a music command. - by TheFlyer - 05.02.2014, 21:29
Re: Making a music command. - by PowerPC603 - 06.02.2014, 05:56

Forum Jump:


Users browsing this thread: 2 Guest(s)