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

Function

getVehicleDistanceTravelled

Server and clientVehiclesTrilogy Hub only

Returns the vehicle's mileage in metres. The server counts it from the driver's movement; teleports do not count. The client sees the value rounded to 100 m.

Syntax

float getVehicleDistanceTravelled(vehicle vehicle)

Arguments

vehiclevehicle
The vehicle.

Returns

Mileage in metres; false for an invalid vehicle.

Example

addCommandHandler("licznik", function(player)
    local veh = getPedOccupiedVehicle(player)
    if veh then
        outputChatBox(("Przebieg: %.1f km"):format(getVehicleDistanceTravelled(veh) / 1000), player)
    end
end)

See also