A vehicle on the server.
var car = Vehicle.create("adder", spawnPoint, 90.0);
car.plate = "HX 001";
car.state.set("ownerLicense", license);
player.ped.warpIntoVehicle(car);
Creating a vehicle server-side is the right default for anything persistent: it exists whether or not any particular client is nearby, it survives that client disconnecting, and it can't be spoofed by a modified client.
Static methods
staticcreate(model:Hash, position:Vector3, heading:Float = 0.0):Vehicle
Spawns a vehicle.
Blocks the calling coroutine until the vehicle is networked, because a
server-created entity is orphaned until a client comes into scope and
has no network ID before then. Returns null if that never happens
within the timeout — which in practice means nobody was near the spawn
point, or the model was not a vehicle.
staticcreateWithSetter(model:Hash, vehicleType:String, position:Vector3, heading:Float = 0.0):Vehicle
Spawns a vehicle using the server setter, which creates the entity without needing a client nearby to own it.
Parameters:
vehicleType | The category: |
|---|
Constructor
Variables
read onlyengineHealth:Float
Engine condition, -4000 to 1000.
Read-only: FXServer exposes no engine-health setter, because engine
damage is simulated by the client that owns the vehicle. To repair one,
tell that client (Net.emitClient(..., vehicle.owner, ...)) and have it
call repair() on its own fivem.client.core.Vehicle.