SA-MP Forums Archive
Passengers can't hear streamed music in vehicle. - 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: Passengers can't hear streamed music in vehicle. (/showthread.php?tid=402729)



Passengers can't hear streamed music in vehicle. - EAsT-OAK_510 - 27.12.2012

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



Re : Passengers can't hear streamed music in vehicle. - [HRD]Mar1 - 27.12.2012

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



Re: Passengers can't hear streamed music in vehicle. - EAsT-OAK_510 - 27.12.2012

Testing it.


Re: Passengers can't hear streamed music in vehicle. - Unte99 - 27.12.2012

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


Re: Passengers can't hear streamed music in vehicle. - EAsT-OAK_510 - 27.12.2012

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?


Re: Passengers can't hear streamed music in vehicle. - Threshold - 27.12.2012

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.


Re: Passengers can't hear streamed music in vehicle. - EAsT-OAK_510 - 28.12.2012

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.


Re: Passengers can't hear streamed music in vehicle. - Grim_ - 28.12.2012

The code he provided does that!