Passengers can't hear streamed music in vehicle.
#1

When the driver plays a certain stream in a car with passengers in it, the passengers can't hear it. Why?

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT || newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        PlayRadioStationForPlayer(playerid);
    }
    if(newstate == PLAYER_STATE_ONFOOT || oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
    {
           StopAudioStreamForPlayer(playerid);
    }
    return 1;
}
Reply
#2

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_PASSENGER)
    {
        PlayRadioStationForPlayer(playerid);
    }
    if(newstate == PLAYER_STATE_DRIVER)
    {
        PlayRadioStationForPlayer(playerid);
    }
    if(newstate == PLAYER_STATE_ONFOOT || oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
    {
           StopAudioStreamForPlayer(playerid);
    }
    return 1;
}
Reply
#3

Testing it.
Reply
#4

First of all... where are you checking if the passenger is in the same car as the driver ?
Reply
#5

Quote:
Originally Posted by Unte99
Посмотреть сообщение
First of all... where are you checking if the passenger is in the same car as the driver ?
Where would I add that?
Reply
#6

Example:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(oldstate == PLAYER_STATE_ONFOOT)
        {
            for(new i = 0; i < MAX_PLAYERS; i++) //foreach is an alternatively better method
            {
                if(IsPlayerConnected(i))
                {
                    if(IsPlayerInVehicle(i, GetPlayerVehicleID(playerid)))
                    {
                         PlayRadioStationForPlayer(i);
                    }
                }
            }
        }
    }
    if(newstate == PLAYER_STATE_ONFOOT && (oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER))
    {
           StopAudioStreamForPlayer(playerid);
    }
    return 1;
}
Only thing that concerns me is that the radio may not stop for everyone in the car when the driver exits the vehicle.
Reply
#7

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
Example:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(oldstate == PLAYER_STATE_ONFOOT)
        {
            for(new i = 0; i < MAX_PLAYERS; i++) //foreach is an alternatively better method
            {
                if(IsPlayerConnected(i))
                {
                    if(IsPlayerInVehicle(i, GetPlayerVehicleID(playerid)))
                    {
                         PlayRadioStationForPlayer(i);
                    }
                }
            }
        }
    }
    if(newstate == PLAYER_STATE_ONFOOT && (oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER))
    {
           StopAudioStreamForPlayer(playerid);
    }
    return 1;
}
Only thing that concerns me is that the radio may not stop for everyone in the car when the driver exits the vehicle.
I would want only the stream to stop for an individual when they step out the vehicle.
Reply
#8

The code he provided does that!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)