PlayAudioStreamForPlayer
#1

Is this going to play for only one player or for all??
Код:
for(new i=0; i<MAX_PLAYERS; i++) 
    	{
        	if(IsPlayerConnected(i)) 
        	{
            	PlayAudioStreamForPlayer(i,"http://s1.vocaroo.com/media/download_temp/Vocaroo_s1NSemW8oOZi.mp3");
            	SendClientMessageToAll(-1, "Hardwell ft. Mitch Crown - Call Me A Spaceman"); 
        	}
    	}
    	return 1;
Reply
#2

It is for all the players.
That is a loop which starts from id 0 and finished to MAX_PLAYERS (value defined 50,100 etc) All the players connected will receive your message + music.

To use just for a player try:


if(IsPlayerConnected(playerid))
{
PlayAudioStreamForPlayer(playerid,"http://s1.vocaroo.com/media/download_temp/Vocaroo_s1NSemW8oOZi.mp3");
SendClientMessage(playerid, 0xFFFFFF, "Hardwell ft. Mitch Crown - Call Me A Spaceman");
}
return 1;
Reply
#3

pawn Код:
for
is used for looping and so the line
pawn Код:
for(new i=0; i<MAX_PLAYERS; i++)
is going to loop through MAX_PLAYERS. Meaning that whenever this function is called it would loop through all players and if they are connected, will begin the audio stream for them.

And also, be careful because SendClientMessageToAll(-1, "Hardwell ft. Mitch Crown - Call Me A Spaceman"); will be announced to the whole server everytime you loop and find a connected player. So to explain, you loop and find that player ID 0 is connected, it will play the stream and send a client message to everyone. The same thing happens for player's 1 and 2, 3 and 4, etc until the chat is spammed with that message.

Instead, just use SendClientMessage(i, -1, message);

Hope I helped!
Reply
#4

Thank you both VERY MUCH :0. You guys helped me a lot
Reply
#5

Код:
SendClientMessageToAll(-1, "Hardwell ft. Mitch Crown - Call Me A Spaceman");
This line going to spam when this loop start.
Like you have MAX_PLAYERS is equal to 100 or 200

it will spam 200 time in chat .

Notice: this is not SendClientMessage // this is SendClientMessageToAll.

I'll not recommend you to use loop and start stream. better to use Boombox type script.
Play music who are in range of that area in which music is playing because the loop you using work only for players
online but if some budy got crash !! and he join again server what you will do start steam again ? that cause lag better you music with position..
Reply
#6

I did this
Код:
CMD:soundtrack1(playerid)
{
	if(IsPlayerConnected(playerid))
	{
		PlayAudioStreamForPlayer(playerid,"http://s1.vocaroo.com/media/download_temp/Vocaroo_s1NSemW8oOZi.mp3");
 		SendClientMessage(playerid, -1, "Hardwell ft. Mitch Crown - Call Me A Spaceman ");
		return 1;
	}
	return 1;
}
And added dialog so player can pick music to play. It is working fine but thank you for explaining
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)