Skip to content

Conversation

@Xenius97
Copy link
Contributor

@Xenius97 Xenius97 commented Nov 14, 2025

Closes #2611

This PR introduces new utility functions for detecting when a player starts entering or exiting a vehicle, as well as retrieving the target vehicle and seat during the enter process. Fully backward compatible.


Shared Functions

isPedEnteringToVehicle
Returns whether the ped is currently beginning to enter a vehicle.

isPedExitingFromVehicle
Returns whether the ped is currently beginning to exit a vehicle.


Client-Only Functions

(On the server side, getPedOccupiedVehicle and getPedOccupiedVehicleSeat already return values immediately when the ped begins entering.)

getPedVehicleEnteringTo
Returns the vehicle the ped is entering.

getPedVehicleEnteringToSeat
Returns the seat the ped is entering.

Client example:

addEventHandler("onClientRender", root, function()
    if isPedEnteringToVehicle(localPlayer) then
        dxDrawText("Entering vehicle...", 100, 100, 300, 200, tocolor(255, 255, 255), 2, "default-bold")
    end

    if isPedExitingFromVehicle(localPlayer) then
        dxDrawText("Exiting vehicle...", 100, 150, 300, 300, tocolor(255, 255, 255), 2, "default-bold")
    end

    local enteringTo = getPedVehicleEnteringTo(localPlayer)
    if enteringTo then
        dxDrawText("Entering to vehicle ID: " .. getVehicleName(enteringTo) .. ", seat: " .. getPedVehicleEnteringToSeat(localPlayer), 100, 200, 400, 400, tocolor(0, 255, 0), 2, "default-bold")
    end
end)

Server example:

setTimer(function()
    local player = getPlayerFromName("AccidentalBoy44")
    if not player then
        iprint("No players", getTickCount())
    else
        if isPedEnteringToVehicle(player) then
            iprint(player:getName() .. " is entering a vehicle", getPedOccupiedVehicle(player), getPedOccupiedVehicleSeat(player), getTickCount())
        end
        if isPedExitingFromVehicle(player) then
            iprint(player:getName() .. " is exiting a vehicle", getPedOccupiedVehicle(player), getPedOccupiedVehicleSeat(player), getTickCount())
        end
    end
end, 500, 0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add getPedOccupiedVehicleStart serverside

1 participant