27.12.2012, 23:21
Example:
Only thing that concerns me is that the radio may not stop for everyone in the car when the driver exits the vehicle.
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;
}