How to Stream Radio for Passengers - 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: How to Stream Radio for Passengers (
/showthread.php?tid=448212)
How to Stream Radio for Passengers -
San1 - 03.07.2013
If i would set a variable such as - new station;
And when i change stations i put station = 1 ; and keep going
How will i make the variable have their own url so passengers and driver can listen to them??
Re: How to Stream Radio for Passengers -
Firewire - 03.07.2013
When the driver is clicking play, it will get HIS vehicle ID and then under this will LOOP through everyone in his car:
pawn Код:
new vehicleradio = GetPlayerVehicleID(playerid); // The vehicle ID is stored inside the integer and called when he clicks play.
When the driver has clicked on a radio and this loop will cycle through the players in his car and play the selected radio:
pawn Код:
foreach(Player, i) // The loop
{
if(GetPlayerVehicleID(i) == vehicleradio && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_PASSENGER && i != playerid) // Checks if the vehicle is the same as the one who typed the command and does other checks to see if there are people in the car
{
// Now that there are people in the car, the audio will play.
PlayAudioStreamForPlayer(i, AUDIO URL);
}
}
This is how I've done it and it's worked for me every time.
Note: If you're not using foreach I can convert it to a standard loop. Foreach is much better for speed.