19.03.2011, 13:53
The problem is that OnPlayerEnterVehicle is called as soon as the person attempts to enter a vehicle. RemovePlayerFromVehicle only works when the person is in the vehicle, but in this case it is being called before the person is even in the vehicle. (Did you also know you can cancel the enter vehicle action, but the callback will still be called?)
So the alternative is to use another method to detect when the player has fully sat in the vehicle, we can do this with OnPlayerStateChange, for example:
Note: Moved to Scripting Discussion, you posted in the wrong section.
So the alternative is to use another method to detect when the player has fully sat in the vehicle, we can do this with OnPlayerStateChange, for example:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER) // Check if the players state has changed to that of a driver
{
if(GetPlayerVehicleID(playerid) == 3 && !IsPlayerAdmin(playerid)) // Only changed the vehicleid part to the GetPlayerVehicleID function because vehicleid is not passed in OnPlayerStateChange, so we need to get it
{
SendClientMessage(playerid, COLOR_RED, "This vehicle is an Admin's vehicle you can't drive it");
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}