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

Function

getElementVelocity

Server and clientElementsIdentical to MTA:SA

Returns the element's velocity. Units: 1 is 50 m/s, so km/h is the vector length times 180.

Syntax

float getElementVelocity(element theElement)

Arguments

theElementelement
The element.

Returns

vx, vy, vz or false.

Example

addEventHandler("onClientRender", root, function()
    local veh = getPedOccupiedVehicle(localPlayer)
    if veh then
        local vx, vy, vz = getElementVelocity(veh)
        local kmh = math.sqrt(vx * vx + vy * vy + vz * vz) * 180
        dxDrawText(("%d km/h"):format(kmh), 20, 500)
    end
end)

See also