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

Function

getElementSpeed

Server and clientElementsTrilogy Hub only

Returns the speed of an element in km/h, mph or m/s.

Syntax

float getElementSpeed(element element [, string unit = "kmh"])

Arguments

elementelement
A vehicle, ped or object.
unitstring, optional = "kmh"
Unit: "kmh", "mph" or "ms".

Returns

The speed; false for an invalid element.

Example

addEventHandler("onClientRender", root, function()
    local veh = getPedOccupiedVehicle(localPlayer)
    if veh then
        dxDrawText(math.floor(getElementSpeed(veh)) .. " km/h", 20, 500)
    end
end)

See also