Unlock car when driver leaves.
#4

That would work... if he wanted the doors to unlock for passengers as well...
You would need to save the vehicle id to a player variable so when they exit, you can check the last vehicle they were in, and change its parameters.

Something like:
pawn Код:
new lastvehicle[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    lastvehicle[playerid] = -1; //They do not have a last vehicle so -1 / invalid
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER)
    {
        if(lastvehicle[playerid] != -1)
        {
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(lastvehicle[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(lastvehicle[playerid], engine, lights, alarm, 1, bonnet, boot, objective);
        }
    }
    if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
    {
        lastvehicle[playerid] = GetPlayerVehicleID(playerid);
    }
    return 1;
}
Reply


Messages In This Thread
Unlock car when driver leaves. - by InActtive™ - 13.01.2013, 04:46
Re: Unlock car when driver leaves. - by mineralo - 13.01.2013, 06:50
Re: Unlock car when driver leaves. - by ThePhenix - 13.01.2013, 06:53
Re: Unlock car when driver leaves. - by Threshold - 13.01.2013, 07:10
Re: Unlock car when driver leaves. - by InActtive™ - 13.01.2013, 21:35

Forum Jump:


Users browsing this thread: 5 Guest(s)