PutPlayerInVehicle

From SA-MP Wiki

Jump to: navigation, search


Description:

Puts a player in a vehicle.


Parameters:
(playerid, vehicleid, seatid)
playeridThe ID of the player to put in a vehicle.
vehicleidThe ID of the vehicle to put the player in.
seatidThe ID of the seat to put the player in.


Return Values:

  • 1: The function executed successfully.
  • 0: The function failed to execute. The player or vehicle don't exist.


Seats:

0 - Driver
1 - Front passenger
2 - Back-left passenger
3 - Back-right passenger
4+ - Passenger seats (coach etc.)
Image:32px-Circle-style-warning.png

Important
Note

If this function is used on a player that is already in a vehicle, other players will still see them in their previous vehicle. To fix this, first remove the player from the vehicle. A fix for this is included in the community-developed fixes.inc.


public OnPlayerEnterVehicle(playerid,vehicleid,ispassanger)
{
    PutPlayerInVehicle(playerid, vehicleid, 0);
    return 1;
}
Image:32px-Circle-style-warning.png

Important
Note

If the seat is invalid or is taken, will cause a crash when they EXIT the vehicle.


Tip

Image:Light_bulb_icon.png

  • You can use GetPlayerVehicleSeat in a loop to check if a seat is occupied by any players.
  • You might use GetVehicleSeats from vSync to get the amount of seats a vehicle has.


Related Functions

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


Related Callbacks

The following callbacks might be useful, as they're related to this function in one way or another.

Personal tools