A vehicle on the client.
var car = Vehicle.create("adder", spawnPoint, 90.0, true);
car.plate = "HAXE 01";
car.setColours(12, 12);
car.lockState = Locked;
Everything here writes through to the game immediately. On a networked
vehicle you don't own, those writes are reverted by the real owner within a
frame or two — call requestControl() first, or make the change on the
server.
Static methods
staticcreate(model:Hash, position:Vector3, heading:Float = 0.0, networked:Bool = true):Vehicle
Spawns a vehicle, streaming its model in first.
Blocks the calling coroutine until the model is ready, and returns
null if the model is invalid or failed to load.
Parameters:
networked | Whether other players can see it. A local vehicle is cheaper but exists on this client only. |
|---|
Constructor
Variables
fuel:Float
Fuel level, 0 to 100.
The base game barely uses this — it refills whenever the vehicle is re-created and doesn't drain on its own. Fuel scripts read and write it on a timer rather than relying on the game.
Methods
markAsPlayerOwned():Void
Marks the vehicle as already owned so it doesn't need hotwiring and won't be reported stolen — what you want for a vehicle a player just took out of their own garage.
setCustomColours(primary:Rgba, ?secondary:Rgba):Void
Paints the vehicle an arbitrary RGB colour, bypassing the game's palette.
inlinesetExtra(extraId:Int, enabled:Bool):Void
Toggles a numbered extra (roof racks, spoilers, decals — model specific).
setMod(modType:Int, modIndex:Int, customTyres:Bool = false):Void
Fits a modification.
The mod kit has to be selected before any mod will apply, which is what
SET_VEHICLE_MOD_KIT(0) does — easy to miss, and the reason mods
"silently don't work" so often. This does it for you.