ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. setPedEnterVehicle

Function

setPedEnterVehicle

Server and clientPedsIdentical to MTA:SA

Tells a ped to get into a vehicle the normal way, walking up and playing the door animation. On the client it only works for the local player: the player walks to a vehicle within 10 m and gets in (other peds give false). On the server it records the ped's task and sends every client the onClientPedEnterRequest event (ped, vehicle, seat), which a client script can handle; the ped itself does not walk up yet on the server.

Syntax

bool setPedEnterVehicle(ped ped [, vehicle vehicle = nil, int/bool seat = 0])

Arguments

pedped
The ped that should get in. On the client it must be localPlayer.
vehiclevehicle, optional = nil
The vehicle. Omitted = the nearest vehicle (client: within 10 m, server: within 10 m).
seatint/bool, optional = 0
Seat: a number 0-8 (0 = driver), true = the nearest free passenger seat (client only), false/omitted = driver.

Returns

true when the order was accepted.

Example

bindKey("g", "down", function()
    if not isPedInVehicle(localPlayer) then
        setPedEnterVehicle(localPlayer, nil, true)
    end
end)

See also