01.06.2014, 20:05
So i have this code:
When i enter a vehicle (passenger or driver) the callback is called and the music starts. But when i teleport out of the vehicle the music won't stop.
I tried to check the states with
but still nothing. The State is changing, i verified, but the callback isn't triggering when i change from driver or passenger to onfoot.
Any ideas?
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if( newstate != PLAYER_STATE_PASSENGER && newstate != PLAYER_STATE_DRIVER )
{
StopAudioStreamForPlayer(playerid);
}
if( newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER )
{
PlayAudioStreamForPlayer( playerid, "radiolink" );
}
return 1;
}
I tried to check the states with
pawn Код:
if( newstate == PLAYER_STATE_ONFOOT )
{
StopAudioStreamForPlayer(playerid);
}
if( oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER )
{
StopAudioStreamForPlayer(playerid);
}
pawn Код:
CMD:getstate(playerid, params[])
{
new string[10];
format(string, sizeof(string), "%d", GetPlayerState(playerid));
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}