How to Stream Radio for Passengers
#1

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??
Reply
#2

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)