15.06.2012, 17:40
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.
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;
}