For TypeScript development there are is a type definitions package available on NPM here
Basic Server Client Script
These two scripts set up a basic way for the server and client to communicate with each other.
Client Script
client.js
// Runs when this resource loadssandbox.on("onResourceLoad", () => {console.log("Loaded Example")sandbox.emitServer("clientReady")});// Runs when the event `serverResponse` is calledsandbox.on("serverResponse", (response) => {// Calls this event on the same sidesandbox.emit("chat:sendMessage", response);})
Server Script
server.js
// Allows clients to call this event, server can call any event on clients without registrationsandbox.registerNetEvent("clientReady")// Runs when the event `clientReady` is calledsandbox.on("clientReady", (client, data) => {// Calls this event on the clientsandbox.emitClient(client,"serverResponse", data);// Alternativelyclient.emit("serverResponse", data)});
Listening to third-party events
Any resource can listen to events from other resources by prefixing the event with the resource name.
Third-party events always run after their first-party variant
An example of listening to other resource loading events
example/server.js
// Listening to 'resource' loadsandbox.on("resource:onResourceLoad", () => {console.log("Resource Loaded")}// Listening to 'chat' loadsandbox.on("chat:onResourceLoad", () => {console.log("Chat Loaded")}// Listening to own loadsandbox.on("onResourceLoad", () => {console.log("Example Loaded")}// Listening to own load through third-partysandbox.on("example:onResourceLoad", () => {console.log("Example Loaded")}