Garry's Mod Wiki

Vehicle:SetVehicleParams

Vehicle:SetVehicleParams( table params )

Description

Sets the vehicle parameters for given vehicle.

Not all variables from the Structures/VehicleParams can be set.
Because this method uses miles per hour but Vehicle:GetVehicleParams returns Hammer units per second, this method incorrectly modifies the vehicle engine's "boostMaxSpeed", "maxRevSpeed" and "maxSpeed" even when not explicitly set in a call to this method.

Workaround: In order to retain the original values for these fields, call Vehicle:GetVehicleParams yourself, convert the mentioned fields from Hammer units per second to miles per hour (1 MPH ≈ 17.6 HU/s in this case) and add them to the table passed into the call to this setter. Avoid doing this repeatedly to avoid floating point inaccuracies over time (store the ready-calculated value for next time if possible).

Arguments

1 table params
The new new vehicle parameters. See Structures/VehicleParams

Example

Adds 25 horsepower to every vehicle spawned.

hook.Add("PlayerSpawnedVehicle", "VehicleParamsExample", function(ply, ent) local params = ent:GetVehicleParams() params.engine.horsepower = params.engine.horsepower + 25 ent:SetVehicleParams(params) end)

Page Links


Special Pages


Wikis

?

Render Time: 40ms

DB GetPage 5
Generate Html 10
SaveChanges (1) 8
Render Body 0
Render Sidebar 14