- Documentation
- Shared functions
- getElementVelocity
Function
getElementVelocity
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)