Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

227
Visualizações
attempt to call a nil value (upvalue 'successCB')

Hello i have a problem and it says attempt to call a nil value (upvalue 'successCB') i have tried different methods but didn't work so i want to know if you guys could help me

Here is the a picture of error

and here is main.lua:20

RegisterNUICallback("main", function(data)
    SetNuiFocus(false, false)
    QBCore.Functions.Notify("Authorization Success" , 'success', 7500)
    successCb()
end)

below also is a short part of the code JS code

    $("#submit").click(function () {
        let inputValue = $("#input").val()
        if (inputValue.length > 4) {
            $.post("http://vny-lvaultcodes/error", JSON.stringify({
                error: "Code cannot be greater than 4"
            }))
            $("#container").fadeOut(250);
            return
        } else if (!inputValue) {
            $.post("http://vny-lvaultcodes/error", JSON.stringify({
                error: "You need to type a 4 digit code for submitting."
            }))
            $("#container").fadeOut(250);
            return
        }
        if(inputValue == code){
            $.post('http://vny-lvaultcodes/main', JSON.stringify({text: inputValue,}));
            $("#container").fadeOut(250);
        } else {
            $.post('http://vny-lvaultcodes/failed', JSON.stringify({}));
            $("#container").fadeOut(250);


        }

also below it is a function to open the ui and stuff

function openCode(show, code, success, fail)
    successCb = success
    failCb = fail
    display = true
    SetNuiFocus(true, true)
    SendNUIMessage({
        type = "open",
        code = code,
    })
end
about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

I'm unfamiliar with fivem but looking at the documentation, I think you've defined your callback incorrectly.

https://docs.fivem.net/docs/scripting-manual/nui-development/nui-callbacks/

RegisterNUICallback not only takes a data value but the callback as well (cb in the document).

In your case successCb would be nil thus when you call successCb() it produces the error.

As such, I'd try one of the following:

RegisterNUICallback("main", function(data, successCb)
    SetNuiFocus(false, false)
    QBCore.Functions.Notify("Authorization Success" , 'success', 7500)
    successCb()
end)
RegisterNUICallback("main", function(data, cb)
    SetNuiFocus(false, false)
    QBCore.Functions.Notify("Authorization Success" , 'success', 7500)
    cb()
end)

Hopefully that helps.

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda