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
  • Gamemode start
  • Server console
  • Unknown chat command
  • Gamemode stop
  • Player connect
  • Player disconnect
  • Player death
  • Player hit
  • Vehicle player use
  • Player key

Was this helpful?

  1. Public API

Events

This page describes server-side events

Gamemode start

start()

Remarks

Arguments

Type

Description

oak.event('start', () => {
    console.log('[info] connection started')
    oak.log('[info] oakwood-node connected')
})

Server console

console(text)

Remarks

Executed on server console input.

Arguments

Type

Description

string

Text

// TODO

Unknown chat command

unknownCommand(pid, text)

Remarks

Arguments

Type

Description

player

Player ID

string

Command Used

oak.event('unknownCommand', (pid, text) => {
    oak.chatSend(pid, `[error] unknown command: ${text}`)
})

Gamemode stop

stop()

Remarks

Happens when the server is shut down.

Arguments

Type

Description

oak.event('start', () => {
    console.log('[info] connection stopped')
})

Player connect

playerConnect(pid)

Remarks

Best place to spawn the player.

Arguments

Type

Description

player

Player ID

oak.event('playerConnect', async pid => {
    console.log('[info] player connected', pid)
    oak.chatBroadcast(`[info] player ${await oak.playerNameGet(pid)} connected.`)
    oak.playerModelSet(pid, "Tommy.i3d")
    oak.playerPositionSet(pid, [-1774.59301758, -4.88487052917, -2.40491962433 ])
    oak.playerHealthSet(pid, 200)
    oak.hudFadeout(pid, 1, 500, 0xFFFFFF)
    oak.hudFadeout(pid, 0, 500, 0xFFFFFF)
    oak.playerSpawn(pid)
})

Player disconnect

playerDisconnect(pid)

Remarks

Happens when the player disconnects or times out.

There's no way to find out if the player timed out as of right now. This will be added later on.

Arguments

Type

Description

player

Player ID

oak.event('playerDisconnect', async pid => {
    oak.chatBroadcast(`[info] player ${await oak.playerNameGet(pid)} disconnected.`)
})

Player death

playerDeath(pid)

Remarks

Arguments

Type

Description

player

Player ID

oak.event('playerDeath', async pid => {
    oak.chatSend(pid, `[info] you died! Get a new life!`)
    oak.playerModelSet(pid, "Tommy.i3d")
    oak.playerPositionSet(pid, [-1774.59301758, -4.88487052917, -2.40491962433 ])
    oak.playerHealthSet(pid, 200)
    oak.hudFadeout(pid, 1, 500, 0xFFFFFF)
    oak.hudFadeout(pid, 0, 500, 0xFFFFFF)
    oak.playerSpawn(pid)
})

Player hit

playerhit(pid, atkr, float)

Remarks

Happens when attacker lands a hit on another player.

Arguments

Type

Description

player

Player ID

player

Attacker ID

float

Damage Dealt

// TODO

Vehicle player use

vehicleUse(veh, pid, success, seatId, enterOrLeave)

Remarks

Success is true if car is unlocked, we can also provide which seat he wants to enter or whether he wants to enter or leave the vehicle.

Arguments

Type

Description

vehicle

Vehicle ID

player

Player ID

int

Success State

int

Seat ID

int

Enter or Leave State

oak.event("vehicleUse", async (veh, pid, success, seatId, enterOrLeave) => {
    if (success) return;

    oak.hudMessage(pid, "This vehicle is locked!", 0xff0000)
})

Player key

playerKey(pid, vkey, down)

Remarks

Arguments

Type

Description

player

Player ID

int

Virtual Key

int

Is Key Down

// TODO
PreviousPublic APINextPlayer

Last updated 5 years ago

Was this helpful?

Executed on player key press. The key codes are documented at .

MSDN page