Listen for Events

This example will tech you how to listen for different server events.

const { World, EPackets } = require("pixelplacejs")

(async () => {

    const CANVAS_ID = 7;

    let world = new World(CANVAS_ID);
    await world.Init();

    world.on(EPackets.NEW_CHAT_MESSAGE, (message) => {
        console.log(`${message.username}: ${message.message}`)
    })

    console.log("PP is running")
})()

Last updated

Was this helpful?