On - server

Use on function when you want to listen from server only.
This declares an event which gets triggered with emit from the server.

Signature

function on(eventName: string, fn: Function) => void

Required arguments

  • eventName: The event name you want to expose.
  • fn: The function to execute when the event get triggered.

Examples

on(
  "foo:kickBar",
                   // We can add callback
  (barId: string, cb: Function => {
    DropPlayer(barId, "Foo doesn't want you anymore!");
    cb("Job is done!");
  }
);