I tried to support promise for dialog's show method and ran into problems implementing it.
It's not just in this one callback, but also in other callbacks, such as OnPlayerDisconnect, which internally calls resolve or reject a promise at one point.
It must be wrapped in a layer of setTimeout or setInterval to work, and there is a minimal probability that setImmediate or process.nextTick will work, and direct calls will not take effect at all.
node version: 16.17.1
samp-node version: 2.1.0
OnDialogResponse(
(
playerid: number,
dialogid: number,
response: number,
listitem: number,
inputbuf: number[]
): number => {
const callback = Dialog.waitingQueue.get(playerid);
if (!callback) return 0;
// bug: does not trigger resolve of promise
// fix: it only works if you put it in an event loop
setTimeout(() => callback.resolve({ response, listitem, inputbuf }));
return 1;
}
);
see here
I tried to support promise for dialog's show method and ran into problems implementing it.
It's not just in this one callback, but also in other callbacks, such as OnPlayerDisconnect, which internally calls resolve or reject a promise at one point.
It must be wrapped in a layer of
setTimeout
orsetInterval
to work, and there is a minimal probability thatsetImmediate
orprocess.nextTick
will work, and direct calls will not take effect at all.node version: 16.17.1 samp-node version: 2.1.0