RemovePlayerFromVehicle

From SA-MP Wiki

Jump to: navigation, search


Description:

Removes/ejects a player from their vehicle.


Parameters:
(playerid)
playeridThe ID of the player to remove from their vehicle.


Return Values:

  • 1: The function executed successfully.
  • 0: The function failed to execute. This means the player is not connected.


Image:32px-Ambox_warning_orange.png

Notes

  • The exiting animation is not synced for other players.
  • This function will not work when used in OnPlayerEnterVehicle, because the player isn't in the vehicle when the callback is called. Use OnPlayerStateChange instead(see the example below).
  • The player isn't removed if he is in a RC Vehicle.


// Example - Players can only drive vehicles if they have 10 score.
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && GetPlayerScore(playerid) < 10) // PlAYER_STATE_DRIVER = 2
    {
        RemovePlayerFromVehicle(playerid);
    }
    return 1;
}

Related Functions

The following functions may be useful, as they are related to this function in one way or another.

Personal tools
Navigation
Toolbox