AudioStream
#1

How do I get AudioStream to play for all?
Reply
#2

[php]
for(new i = 0;i < MAX_PLAYERS; i++)
{
PlayAudioStreamForPlayer(i, "url");
}
Reply
#3

Quote:
Originally Posted by Nuke547
View Post
[php]
for(new i = 0;i < MAX_PLAYERS; i++)
{
PlayAudioStreamForPlayer(i, "url");
}
You need to end the /php also but you should use the tag [ pawn ][ /pawn ]

Btw the above code will play an audio stream for every player!

EDIT : I have a much better code
pawn Code:
for(new i = 0; i < MAX_PLAYERS; i++)//loops through all players
{
   if(IsPlayerConnected(i))//checks if player is connected
   {
   StopAudioStreamForPlayer(i);//stops the audio stream if any is playing.If none is playing nothing will happen.
   PlayAudioStreamForPlayer(i, "http://somafm.com/tags.pls");//plays the music.U can put any link.Just change somafm.com/tags.pls
}
}
Reply
#4

Fixed, thanks guys!
Reply
#5

Fixed!

EDIT: All good mate!
Reply
#6

One problem, only ID 0 hears the radio.
Reply
#7

Quote:
Originally Posted by Chrillzen
View Post
One problem, only ID 0 hears the radio.
No It makes the loop and everyone in the SERVER, who are CONNECTED, can hear the AudioStream.

-FalconX
Reply
#8

Not for me, I tested with 4 players that were connected, only id 0 hears the radio. Somethign wrong with the code I guess?

My code:
Code:
for(new i = 0; i < MAX_PLAYERS; i++)//loops through all players
{
   if(IsPlayerConnected(i))//checks if player is connected
   {
		if (PlayerInfo[playerid][pRadiouse] == 1) return SendClientMessage(playerid, COLOR_RED, "ERROR: "COL_WHITE"Du har redan lagt ner en radio.");
		{
		 		new Float:Distance = 17.0;
				PlayAudioStreamForPlayer(i, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=2147127", radioX[playerid], radioY[playerid], radioZ[playerid], Distance, 1);//plays the music.U can put any link.Just change somafm.com/tags.pls
			   	GetPlayerPos(playerid, radioX[playerid], radioY[playerid], radioZ[playerid]);
				GetPlayerFacingAngle(playerid, radioA[playerid]);
				boombox[playerid] = CreateObject(2103, radioX[playerid], radioY[playerid] +1, radioZ[playerid] -1, 0.0, 0.0, radioA[playerid] + 90);
				PlayerInfo[playerid][pRadiouse] = 1;
}
 			}
 			}
 			}
Reply
#9

Quote:
Originally Posted by Chrillzen
View Post
Not for me, I tested with 4 players that were connected, only id 0 hears the radio. Somethign wrong with the code I guess?
pawn Code:
for(new i = 0; i < MAX_PLAYERS; i++)//loops through all players
{
   if(IsPlayerConnected(i))//checks if player is connected
   {
      StopAudioStreamForPlayer(i);//stops the audio stream if any is playing.If none is playing nothing will happen.
      PlayAudioStreamForPlayer(i, "http://somafm.com/tags.pls");//plays the music.U can put any link.Just change somafm.com/tags.pls
   }
}
Put this in the OnPlayerConnect, and try. Ths code is not wrong it will work you might have been doing something wrong.

-FalconX
Reply
#10

I think I might have fixed it, I had something wrong in my code. I can't test it now tought.
Reply
#11

Yes it can be..

Add this under OnPlayerRequestClass

pawn Code:
PlayAudioStreamForPlayer(i,"your audio link");
and Add This under OnPlayerSpawn
pawn Code:
StopAudioStreamForPlayer(i))
hope i am Correct. and don't forget to add
pawn Code:
for(new i = 0; i < MAX_PLAYERS; i++)
}
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)