Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

226
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda