Events
This page describes server-side events
Gamemode start
start()
oak.event('start', () => {
console.log('[info] connection started')
oak.log('[info] oakwood-node connected')
})
Server console
console(text)
Executed on server console input.
Arguments
Unknown chat command
unknownCommand(pid, text)
oak.event('unknownCommand', (pid, text) => {
oak.chatSend(pid, `[error] unknown command: ${text}`)
})
Gamemode stop
stop()
Happens when the server is shut down.
Arguments
oak.event('start', () => {
console.log('[info] connection stopped')
})
Player connect
playerConnect(pid)
Best place to spawn the player.
Arguments
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)
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
oak.event('playerDisconnect', async pid => {
oak.chatBroadcast(`[info] player ${await oak.playerNameGet(pid)} disconnected.`)
})
Player death
playerDeath(pid)
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)
Happens when attacker lands a hit on another player.
Arguments
Vehicle player use
vehicleUse(veh, pid, success, seatId, enterOrLeave)
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
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)
Executed on player key press. The key codes are documented at MSDN page.
Arguments