diff --git a/package/client/resource/callback/index.ts b/package/client/resource/callback/index.ts index 9b18b429..c1697f07 100644 --- a/package/client/resource/callback/index.ts +++ b/package/client/resource/callback/index.ts @@ -42,11 +42,11 @@ export function triggerServerCallback( } export function onServerCallback(eventName: string, cb: (...args) => any) { - onNet(`__ox_cb_${eventName}`, (resource: string, key: string, ...args) => { + onNet(`__ox_cb_${eventName}`, async (resource: string, key: string, ...args) => { let response: any; try { - response = cb(...args); + response = await cb(...args); } catch (e: any) { console.error(`an error occurred while handling callback event ${eventName}`); console.log(`^3${e.stack}^0`); diff --git a/package/server/resource/callback/index.ts b/package/server/resource/callback/index.ts index d1e9a6c2..321bd7ad 100644 --- a/package/server/resource/callback/index.ts +++ b/package/server/resource/callback/index.ts @@ -26,12 +26,12 @@ export function triggerClientCallback( } export function onClientCallback(eventName: string, cb: (playerId: number, ...args) => any) { - onNet(`__ox_cb_${eventName}`, (resource: string, key: string, ...args) => { + onNet(`__ox_cb_${eventName}`, async (resource: string, key: string, ...args) => { const src = source; let response: any; try { - response = cb(src, ...args); + response = await cb(src, ...args); } catch (e: any) { console.error(`an error occurred while handling callback event ${eventName}`); console.log(`^3${e.stack}^0`);