Client
Trigger Server Callback
triggerServerCallback
triggerServerCallback(eventName, delay, ...args)
- eventName:
string
- delay:
number
ornull
- Amount of time until this callback can be triggered again
- ..args:
any
Register Client Callback
onServerCallback
onServerCallback(eventName, cb)
- eventName:
string
- cb:
function
(...args:any
)
Usage Example
For this example to fully make sense take a look at the example on the server page for the callbacks.
import { onServerCallback, triggerServerCallback } from '@overextended/ox_lib/client'
onServerCallback('test:client', (...args: [number, number, string]) => {
console.log(args);
return {
clientValue: 'Value from the client',
};
});
setTimeout(async () => {
const args = [1, null, 3, null, null, 6];
const response = await triggerServerCallback<{ serverValue: number }>('test:server', 1, args);
if (!response) return;
console.log('Response from server', response);
}, 100);