Vehicle Locking
#1

Alright, I have this in my OnPlayerEnterVehicle:

pawn Код:
if(CarInfo[vehicleid][CarLock] == 1)
    {
        ClearAnimations(playerid);
    }
But would it work the same way at OnPlayerExitVehicle?

Like prevent players from leaving.
Reply
#2

If you want to prevent players from leaving a vehicle use PutPlayerInVehicle under OnPlayerStateChange if their state changes to 1 (onfoot). You'll have to save the player's last vehicle in a variable, just do that if newstate == 2 or 3 with GetPlayerVehicleID.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 1 && oldstate == 2) // Exited vehicle as DRIVER
    {
        PutPlayerInVehicle(playerid, GetPVarInt(playerid, "lastveh"), 0);
    }
    if(newstate == 2) // Entered vehicle as driver, save last vehicle
    {
        SetPVarInt(playerid, "lastveh", GetPlayerVehicleID(playerid));
    }
    return 1;
}
Un-tested.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)