Template Guide
Below is a list of functions that are available to use in your template.
Configure
In app.svelte there is an object that you can configure.
CONFIG.set({
fallbackResourceName: 'debug',
allowEscapeKey: true,
});- fallbackResourceName:
stringThe resource name to use if the resource name is not found while using localhost in the game. - allowEscapeKey:
booleanAllow the escape key to close the UI.
Client
SendNUIEvent
This is basically a shorthand for SendNUIMessage but it will automatically structure the data for you suitable for the UI.
SendNUIEvent(event, data)- event:
stringThe event name to send to the NUI - data:
anyThe data to send to the NUI
UI
SendEvent
Send an event to the Client
SendEvent(event, data);- event:
stringThe event name to send to the client - data:
anyThe data to send to the client
TempReceiveEvent
A disposable listener for an event from the Client.
YOU MUST DISPOSE. IF NOT THE LISTENER WILL KEEP LISTENING AND WILL CAUSE MEMORY LEAKS.
// Listen for the event
const dispose = TempReceiveEvent(event, callback);
// Dispose the listener
dispose();- event:
stringThe event name to listen for - callback:
functionThe callback to run when the event is received
Return:
- dispose:
functionThe function to call to dispose the listener
Note
There are other functions available but as a developer using the template properly, you dont really need to use them.
These functions include:
ReceiveEventDebugEventSendDebugEventReceiveDebugEventCallback