- Documentation
- Shared functions
- getVehiclePerformance
Function
getVehiclePerformance
Returns a vehicle's performance in a player-friendly form: power in kW and HP, torque, mass, 0-100 km/h time and top speed. You can pass a vehicle (its engine and wear are used) or a model number, optionally with an engine to compare.
Syntax
table getVehiclePerformance(vehicle/int vehicleOrModel [, table spec = nil, float wear = 0])Arguments
vehicleOrModelvehicle/int- A vehicle or a model ID.
spectable, optional = nil- An engine to calculate instead of the current one (as in
setVehicleEngine). wearfloat, optional = 0- Wear 0..1 (for a vehicle without
spec: its own).
Returns
powerKW, powerHP, torque, mass, accel100 (s), topSpeed (km/h), engine; false for an unknown model.
Example
addCommandHandler("osiagi", function(player)
local vehicle = getPedOccupiedVehicle(player)
if not vehicle then return end
local p = getVehiclePerformance(vehicle)
outputChatBox(("%d KM, 0-100 w %.1f s, Vmax %d km/h"):format(p.powerHP, p.accel100, p.topSpeed), player)
end)
See also
getVehicleEngineReturns the vehicle's engine: the one fitted withsetVehicleEngineor, when none was fitted, the factory engine calculated from game data (withfactory = true). The second value is wear 0..1. Works on both sides.calculateEngineHandlingCalculates which handling fields an engine would give in a model, without fitting it. It returns whatsetVehicleEnginewould write into the vehicle, so it suits a preview in an engine shop.