Skip to content

OnPlayerStateChange in vehicle bug #640

@PazzOnee

Description

@PazzOnee

If you are in vehicle (PLAYER_STATE_DRIVER OR PLAYER_STATE_PASSANGER), and you die, OnPlayerStateChange will output oldstate PLAYER_STATE_SPAWNED, and newstate PLAYER_STATE_NONE, than PLAYER_STATE_ONFOOT, so if i try make per player timer when they sit as driver, and die, timer won't kill when newstate != PLAYER_STATE_DRIVER

In samp this work correctly, when player die in vehicle, oldstate first is PLAYER_STATE_DRIVER, than others

code example

static speedoMeter[MAX_PLAYERS] = {-1, ...};

OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_DRIVER) 
    {
        KillTimer(speedoMeter[playerid]);
    }
    if(newstate == PLAYER_STATE_DRIVER)
    {
        speedoMeter[playerid] = SetTimerEx(...);
    }
}

So, sit in vehicle as driver, kill yourself (SetPlayerHealth(...)), or explode in gas station, then see that oldstate will not be PLAYER_STATE_DRIVER, though you was PLAYER_STATE_DRIVER

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions