Vehicle
This page describes the vehicle API
vehicleList()
Retrieves all online vehicle IDs.
vehicleSpawn(string, vec3, float)
Spawns the vehicle at a specified position and heading direction.
You can use the following listing for vehicle model names.
Vehicle ID if spawned, -1 if failed.
oak.cmd('car', async (pid, model) {
const m = parseInt(model)
if (m === NaN) {
return oak.chatSend(pid, "[error] provided argument should be a valid number")
}
oak.chatSend(pid, "[info] spawning vehicle model ${vehicleModels[m][0]}")
let pos = await oak.playerPositionGet(pid)
let heading = await oak.playerHeadingGet(pid)
if (adjustPos === true) {
let dir = await oak.playerDirectionGet(pid)
pos = pos.map((p, i) => p + dir[i] * 1.5)
heading -= 90.0
}
oak.vehicleSpawn(vehicleModels[m][1], pos, heading)
})
vehicleDespawn(vehicle)
Despawns a vehicle
0 if successful, -1 if failed.
vehicleInvalid(vehicle)
Checkes whether the vehicle ID is invalid.
1 if invalid, 0 if valid otherwise.
vehicleRepair(vehicle)
Repairs the vehicle.
0 if successful, -1 if failed.
vehiclePositionSet(vehicle, vec3)
Sets the vehicle position.
0 if successful, -1 if failed.
vehicleDirectionSet(vehicle, vec3)
Sets the vehicle forward direction vector.
0 if successful, -1 if failed.
vehicleHeadingSet(vehicle, float)
Sets the vehicle heading angle.
Uses a ±180 degree format.
0 if successful, -1 if failed
vehicleFuelSet(vehicle, float)
Set vehicle fuel level
0 if successful, -1 if failed
Set transparency
vehicleTransparencySet(vehicle, float)
Set vehicle transparency value
0-1 range.
0 if successful, -1 if failed
vehicleLockSet(vehicle, int)
Locks/Unlocks the vehicle
0 for unlock, 1 for lock.
0 if successful, -1 if failed
vehiclePositionGet(vehicle)
Gets the vehicle position.
vehicleDirectionGet(vehicle)
Gets the vehicle direction.
Returns vehicle direction
vehicleHeadingGet(vehicle)
Retrieves the vehicle's heading angle.
Uses a ±180 degree format.
float heading angle
vehicleFuelGet(vehicle)
Retrieves the vehicle's fuel level.
Get transparency
vehicleTransparencyGet(vehicle)
Retrieves the vehicle's transparency value.
0-1 range.
float transparency value
vehicleLockGet(vehicle)
Retrieves the vehicle's lock state.
0 for unlocked, 1 for locked.
int lock state
There are several visibility options you can set for the vehicle:
Vehicle's blip visibility on the map
Vehicle's marker visibility on the radar
Vehicle's collision state
Vehicle's transparency state
vehicleVisibilityGet(vehicle, visibility_type)
Retrieves the current vehicle's visibility.
None.
int vehicle visibility option value
vehicleVisibilitySet(vehicle, visibility_type, int)
Sets the current vehicle's visibility setting.