Get vehicles
vehicleList()
Retrieves all online vehicle IDs.
Arguments
Returns
Vehicle IDs collection.
Spawn
vehicleSpawn(string, vec3, float)
Spawns the vehicle at a specified position and heading direction.
You can use the following for vehicle model names.
Arguments
Returns
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)
})
Despawn
vehicleDespawn(vehicle)
Despawns a vehicle
Arguments
Returns
0 if successful, -1 if failed.
Invalid
vehicleInvalid(vehicle)
Checkes whether the vehicle ID is invalid.
Arguments
Returns
1 if invalid, 0 if valid otherwise.
Repair
vehicleRepair(vehicle)
Repairs the vehicle.
Arguments
Returns
0 if successful, -1 if failed.
Set position
vehiclePositionSet(vehicle, vec3)
Sets the vehicle position.
Arguments
Returns
0 if successful, -1 if failed.
Set direction
vehicleDirectionSet(vehicle, vec3)
Sets the vehicle forward direction vector.
Arguments
Returns
0 if successful, -1 if failed.
Set heading
vehicleHeadingSet(vehicle, float)
Sets the vehicle heading angle.
Uses a ±180 degree format.
Arguments
Returns
0 if successful, -1 if failed
Set fuel
vehicleFuelSet(vehicle, float)
Set vehicle fuel level
Arguments
Returns
0 if successful, -1 if failed
Set transparency
vehicleTransparencySet(vehicle, float)
Set vehicle transparency value
0-1 range.
Arguments
Returns
0 if successful, -1 if failed
Set lock
vehicleLockSet(vehicle, int)
Locks/Unlocks the vehicle
0 for unlock, 1 for lock.
Arguments
Returns
0 if successful, -1 if failed
oak.cmd('lock', async (pid, state) => {
const veh = await oak.vehiclePlayerInside(pid)
if (await oak.vehicleInvalid(veh)) return;
state = parseInt(state)
stateMsg = (state === 0) ? "unlocked" : "locked"
oak.chatSend(pid, `Vehicle is now ${stateMsg}!`)
oak.vehicleLockSet(veh, state)
})
Get position
vehiclePositionGet(vehicle)
Gets the vehicle position.
Arguments
Returns
Returns vehicle position
Get direction
vehicleDirectionGet(vehicle)
Gets the vehicle direction.
Arguments
Returns
Returns vehicle direction
Get heading
vehicleHeadingGet(vehicle)
Retrieves the vehicle's heading angle.
Uses a ±180 degree format.
Arguments
Returns
float
heading angle
Get fuel
vehicleFuelGet(vehicle)
Retrieves the vehicle's fuel level.
Arguments
Returns
float
fuel level
Get transparency
vehicleTransparencyGet(vehicle)
Retrieves the vehicle's transparency value.
0-1 range.
Arguments
Returns
float
transparency value
Get lock
vehicleLockGet(vehicle)
Retrieves the vehicle's lock state.
0 for unlocked, 1 for locked.
Arguments
Returns
int
lock state
Visibility
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
Get visibility
vehicleVisibilityGet(vehicle, visibility_type)
Retrieves the current vehicle's visibility.
None.
Arguments
Returns
int
vehicle visibility option value
Set visibility
vehicleVisibilitySet(vehicle, visibility_type, int)
Sets the current vehicle's visibility setting.
None.
Arguments
Returns
0 if successful