RegisterNUICallback not triggered

Hi, i would like to create a nui script, but somehow the RegisterNUICallback event not beeing trigered

the resource name: characterSelect

libary structure:

  • characterSelect

    • client

      • html

        • characterSelect.js
        • index.html
        • style.css
      • characterSelect_c.lua

    • __resource.lua


characterSelect_c.lua (client)

RegisterNUICallback('inf', function(data, cb)
    SetNuiFocus(false,false)

    TriggerEvent("chat:addMessage", {
        color = {0, 255, 0},
        multiline = true,
        args = {"[SUCESS]: ", "something"}
    })

    cb('ok')
end)

characterSelect.js

$(function(){
    $('#wrapper').hide();
    
    window.addEventListener('message', function(event){
        var item = event.data;

        if (item.command && item.command == 'enableUI'){
            $('#wrapper').show();
            
        }else if(item.command && item.command == 'disableUI'){
            $('#wrapper').hide();
        }
    },false);


    $('#third').click(function() {
        $.post('http://characterSelect/inf', JSON.stringify({}));
    
        $('#wrapper').hide();
    });

});

The click event is working, because it hides the wrapper div
I don’t know what’s wrong

Kinda guessing, but try renaming your resource and using all lowercase. characterselect

2 Likes

its RegisterNuiCallback, not RegisterNUICallback

I tried, but nothing changed. I renamed the resource and the files too

If i renaming, than occurs an error in F8 console --> attempt to call a nil value (global
‘RegisterNuiCallback’)

Ops… sorry.

I was wrong, it was RegisterNUICallback. The searchbar is broken for me atm so…

maby its the uppercase resource name that is causing the issue, i remember me having that issue a while back. try to do

$.post(‘http://characterselect/inf’, JSON.stringify({}));

and then renaming the resource folder of cource

2 Likes

Yes it work now, jut i forgot to rename the javascript file name in the index.html

But the problem was the resourcename contained uppercase letter

Thx guys for help

nice, happy to help

by repeating the same answer I gave, big help…