Nui Callback does not work

Hello, I am trying to make an NUI callback so I can unfocus the NUI, but I can’t register it or something?

I can’t find the error so I decided to ask here!

client.ts

RegisterNuiCallbackType('exit')

on('_cfx_nui:exit', (data: any, cb: any) => {
    console.log("exit")
    cb("exit")
})

index.js

document.addEventListener('keydown', function(event) {
        if (event.key==="Escape") {
            $(".main").hide();
            $.post("https://character_creator/exit", JSON.stringify({
                type: "exit"
            }));
            console.log("sent");
        }
    });

I get the sent in the console, but the exit never arrives in the console

If you need any more information just tell me so in the comments

I found the problem,
I forgott an underscore in the on() function

Pervious code:

on('_cfx_nui:exit', (data: any, cb: any) => {
    console.log("exit")
    cb("exit")
})
on('__cfx_nui:exit', (data: any, cb: any) => {
    cb("exit")
    console.log("exit")
})

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.