NodeJS
This page describes how to use the NodeJS package.
Set up your NodeJS environment
const {createClient} = require('oakwood')
const oak = createClient()
oak.event('start', async () => {
console.log("[info] connected to the server")
oak.log("[info] hello world from nodejs")
})
oak.event('playerConnect', async pid => {
console.log('[info] player connected', pid)
oak.playerPositionSet(pid, [-1774.59301758, -4.88487052917, -2.40491962433])
oak.playerHealthSet(pid, 200)
oak.playerSpawn(pid)
})
oak.cmd('goto', async (pid, targetid) => {
const tid = parseInt(targetid)
if (tid === NaN) {
return oak.chatSend(pid, `[error] provided argument should be a valid number`)
}
if (await oak.playerInvalid(tid)) {
return oak.chatSend(pid, `[error] player you provided was not found`)
}
/* get target position */
const pos = await oak.playerPositionGet(tid)
/* set our player position */
oak.playerPositionSet(pid, pos)
})Things to note
Last updated