Help with seatbelt
#20

You have to use OnPlayerExitVehicle, and OnPlayerState, it only gets called when a player is actually out of the car, at which point he has no vehicle ID. That's what I think is causing your code not to work.

Under OnPlayerEnterVehicle, you get the seat id and store it into a global variable. Then on OnPlayerExitVehicle you put them back in the same vehicle with that global var that holds the seat id.

pawn Code:
new
    // at the top of your script
     gSeatID[MAX_PLAYERS]; // a global var for the seat ID

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    // if either they entered as a passenger or driver
    // adjust their seat it
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        gSeatID[playerid] = GetPlayerVehicleSeat(playerid);
    }
    return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(Player[playerid][Seatbelt] = 1)
    {
        // so if the player exits the vehicle
        // and they're still buckled up
        // you put them back in the vehicle
        // in their global seat ID
        PutPlayerInVehicle(playerid, vehicleid, gSeatID[playerid]);
        /*
         *  You would put the code that notifies the player
         *  that they are not unbuckled yet.
         *
         */

        return 1;
    }
    return 1;
}
Reply


Messages In This Thread
Exiting vehicle with sb on - by Stefand - 11.06.2012, 15:20
Re: Help with seatbelt - by Stefand - 11.06.2012, 16:06
Re: Help with seatbelt - by JhnzRep - 11.06.2012, 16:08
Re: Help with seatbelt - by Stefand - 13.06.2012, 05:34
Re: Help with seatbelt - by PrawkC - 13.06.2012, 05:37
Re: Help with seatbelt - by Stefand - 13.06.2012, 10:10
Re: Help with seatbelt - by Stefand - 13.06.2012, 12:58
Re: Help with seatbelt - by Jonny5 - 13.06.2012, 13:06
Re: Help with seatbelt - by Stefand - 13.06.2012, 13:25
Re: Help with seatbelt - by Jonny5 - 13.06.2012, 13:26
Re: Help with seatbelt - by Stefand - 13.06.2012, 13:37
Re: Help with seatbelt - by newbienoob - 13.06.2012, 13:41
Re: Help with seatbelt - by Stefand - 13.06.2012, 13:42
Re: Help with seatbelt - by Stefand - 14.06.2012, 10:55
Re: Help with seatbelt - by Faisal_khan - 14.06.2012, 11:02
Re: Help with seatbelt - by Stefand - 14.06.2012, 13:05
Re: Help with seatbelt - by Faisal_khan - 14.06.2012, 16:23
Re: Help with seatbelt - by Stefand - 15.06.2012, 17:10
Re: Help with seatbelt - by jessejanssen - 15.06.2012, 17:15
Re: Help with seatbelt - by ReneG - 15.06.2012, 17:40

Forum Jump:


Users browsing this thread: 3 Guest(s)