In JavaScript
Basic Server Client Script
These two scripts set up a basic way for the server and client to communicate with each other.
Client Script
// Runs when this resource loads
sandbox.on("onResourceLoad", () => {
console.log("Loaded Example")
sandbox.emitServer("clientReady")
});
// Runs when the event `serverResponse` is called
sandbox.on("serverResponse", (response) => {
// Calls this event on the same side
sandbox.emit("chat:sendMessage", response);
})Server Script
Listening to third-party events
Any resource can listen to events from other resources by prefixing the event with the resource name.
An example of listening to other resource loading events
Last updated
Was this helpful?