SA-MP Forums Archive
AudioStream - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: AudioStream (/showthread.php?tid=321929)



AudioStream - Chrillzen - 29.02.2012

How do I get AudioStream to play for all?


Re: AudioStream - Nuke547 - 29.02.2012

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


Re: AudioStream - Ballu Miaa - 29.02.2012

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
}
}



Re: AudioStream - Chrillzen - 29.02.2012

Fixed, thanks guys!


Re: AudioStream - Ballu Miaa - 29.02.2012

Fixed!

EDIT: All good mate!


Re: AudioStream - Chrillzen - 01.03.2012

One problem, only ID 0 hears the radio.


Re: AudioStream - FalconX - 01.03.2012

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


Re: AudioStream - Chrillzen - 01.03.2012

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;
}
 			}
 			}
 			}



Re: AudioStream - FalconX - 01.03.2012

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


Re: AudioStream - Chrillzen - 01.03.2012

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


Re: AudioStream - Jarnu - 06.06.2012

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++)
}