Oakwood
  • Introduction
  • Server Setup
  • Public API
    • Events
    • Player
    • Vehicle
    • HUD
    • Camera
    • Chat
    • Vehicle-Player
    • Miscellaneous
  • Languages
    • NodeJS
  • Server API
  • Assets
    • Asset: Vehicle Models
    • Asset: Player models
  • Tutorials
    • Build Your Own Language Support
      • 1. Overview
      • 2. Connection
      • 3. Native Calls
      • 4. Events
      • 5. Wrap-up
Powered by GitBook
On this page
  • Get vehicles
  • Spawn
  • Despawn
  • Invalid
  • Repair
  • Set position
  • Set direction
  • Set heading
  • Set fuel
  • Set transparency
  • Set lock
  • Get position
  • Get direction
  • Get heading
  • Get fuel
  • Get transparency
  • Get lock
  • Visibility
  • Get visibility
  • Set visibility

Was this helpful?

  1. Public API

Vehicle

This page describes the vehicle API

PreviousPlayerNextHUD

Last updated 5 years ago

Was this helpful?

Get vehicles

vehicleList()

Retrieves all online vehicle IDs.

Remarks

Arguments

Type

Description

Returns

Vehicle IDs collection.

// TODO

Spawn

vehicleSpawn(string, vec3, float)

Spawns the vehicle at a specified position and heading direction.

Remarks

You can use the following for vehicle model names.

Arguments

Type

Description

string

Model name

vec3

Position

float

Heading direction

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

Remarks

Arguments

Type

Description

vehicle

Vehicle ID

Returns

0 if successful, -1 if failed.

// TODO

Invalid

vehicleInvalid(vehicle)

Checkes whether the vehicle ID is invalid.

Remarks

Arguments

Type

Description

vehicle

Vehicle ID

Returns

1 if invalid, 0 if valid otherwise.

// TODO

Repair

vehicleRepair(vehicle)

Repairs the vehicle.

Remarks

Arguments

Type

Description

vehicle

Vehicle ID

Returns

0 if successful, -1 if failed.

// TODO

Set position

vehiclePositionSet(vehicle, vec3)

Sets the vehicle position.

Remarks

Arguments

Type

Description

vehicle

Vehicle ID

vec3

Vehicle Position

Returns

0 if successful, -1 if failed.

// TODO

Set direction

vehicleDirectionSet(vehicle, vec3)

Sets the vehicle forward direction vector.

Remarks

Arguments

Type

Description

vehicle

Vehicle ID

vec3

Vehicle Direction

Returns

0 if successful, -1 if failed.

// TODO

Set heading

vehicleHeadingSet(vehicle, float)

Sets the vehicle heading angle.

Remarks

Uses a ±180 degree format.

Arguments

Type

Description

vehicle

Vehicle ID

float

±180 degree angle

Returns

0 if successful, -1 if failed

// TODO

Set fuel

vehicleFuelSet(vehicle, float)

Set vehicle fuel level

Remarks

Arguments

Type

Description

vehicle

Vehicle ID

float

Fuel level

Returns

0 if successful, -1 if failed

// TODO

Set transparency

vehicleTransparencySet(vehicle, float)

Set vehicle transparency value

Remarks

0-1 range.

Arguments

Type

Description

vehicle

Vehicle ID

float

transparency value

Returns

0 if successful, -1 if failed

// TODO

Set lock

vehicleLockSet(vehicle, int)

Locks/Unlocks the vehicle

Remarks

0 for unlock, 1 for lock.

Arguments

Type

Description

vehicle

Vehicle ID

int

Lock State

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.

Remarks

Arguments

Type

Description

vehicle

Vehicle ID

Returns

Returns vehicle position

// TODO

Get direction

vehicleDirectionGet(vehicle)

Gets the vehicle direction.

Remarks

Arguments

Type

Description

vehicle

Vehicle ID

Returns

Returns vehicle direction

// TODO

Get heading

vehicleHeadingGet(vehicle)

Retrieves the vehicle's heading angle.

Remarks

Uses a ±180 degree format.

Arguments

Type

Description

vehicle

Vehicle ID

Returns

float heading angle

// TODO

Get fuel

vehicleFuelGet(vehicle)

Retrieves the vehicle's fuel level.

Remarks

Arguments

Type

Description

vehicle

Vehicle ID

Returns

float fuel level

// TODO

Get transparency

vehicleTransparencyGet(vehicle)

Retrieves the vehicle's transparency value.

Remarks

0-1 range.

Arguments

Type

Description

vehicle

Vehicle ID

Returns

float transparency value

// TODO

Get lock

vehicleLockGet(vehicle)

Retrieves the vehicle's lock state.

Remarks

0 for unlocked, 1 for locked.

Arguments

Type

Description

vehicle

Vehicle ID

Returns

int lock state

// TODO

Visibility

There are several visibility options you can set for the vehicle:

Name

Description

VISIBILITY_ICON

Vehicle's blip visibility on the map

VISIBILITY_RADAR

Vehicle's marker visibility on the radar

VISIBILITY_COLLISION

Vehicle's collision state

VISIBILITY_MODEL

Vehicle's transparency state

Get visibility

vehicleVisibilityGet(vehicle, visibility_type)

Retrieves the current vehicle's visibility.

Remarks

None.

Arguments

Type

Description

vehicle

Vehicle ID

visibility_type

Visibility option

Returns

int vehicle visibility option value

// TODO

Set visibility

vehicleVisibilitySet(vehicle, visibility_type, int)

Sets the current vehicle's visibility setting.

Remarks

None.

Arguments

Type

Description

vehicle

Vehicle ID

visibility_type

Visibility option

int

Visibility state

Returns

0 if successful

// TODO
listing