luafivem

SCRIPT ERROR: @essentialmode/server/main.lua:126: attempt to call a nil value (global 'registerUser')


I have a problem on my FiveM server in GTAV. So, I have essentialmode script.

After a new user come out to server, this happen:

[script:essentialmode] > fn (@essentialmode/server/main.lua:126)

My main.lua configuration from 111 line:

RegisterServerEvent('es:firstJoinProper')
AddEventHandler('es:firstJoinProper', function()
    local Source = source
    Citizen.CreateThread(function()
        local id
        for k,v in ipairs(GetPlayerIdentifiers(Source))do
            if string.sub(v, 1, string.len(settings.defaultSettings.identifierUsed .. ":")) == (settings.defaultSettings.identifierUsed .. ":") then
                id = v
                break
            end
        end

        if not id then
            DropPlayer(Source, "SteamID not found, please try reconnecting with Steam open.")
        else
            registerUser(identifier, Source)
            justJoined[Source] = true
    
        end

        return
    end)
end)

Any thoughts to solve this problem?


Solution

  • I don't know FiveM but a quick websearch yielded this:

    https://github.com/rudzboy/fivem-essentialmode/search?q=server_script

    which contains stuff like this:

    -- Server
    server_script 'server/classes/player.lua'
    server_script 'server/classes/groups.lua'
    server_script 'server/player/login.lua'
    server_script 'server/main.lua'
    server_script 'server/util.lua'
    

    and this:

    https://docs.fivem.net/docs/scripting-reference/resource-manifest/resource-manifest/

    You most likely did not execute login.lua which defines registerUser, befor calling it in main.lua

    You'll need a resource manifest that executes those files in the correct order like in the examples given above and in the documentation.