Hello, I have a problem with my code it shows me the error:
image

Do you have any idea please ?

RegisterCommand("givecoins", function(source, args) 
    if source == 0 then 
        print('vous ne pouvez pas give console ') 
        return
    end
    if permCoins.Staff[getLicense(source)] then
        local id = args[1]
        local identifier = GetPlayerIdentifier(id)
        local coins = args[2]
        if id then
            local tPlayer = ESX.GetPlayerFromId(id)
            if tPlayer then
                local _, fivemid = GetIdentifiers(id)['fivem']:match("([^:]+):([^:]+)")
                if (fivemid) then
                    local license = GetIdentifiers(id)['license'];
                    if (license) then
                        tPlayer.showNotification('Chargement de la requête...')
                        if tonumber(coins) then
                            LiteMySQL:Insert('tebex_players_wallet', {
                                identifiers = fivemid,
                                transaction = "Give point(s) : "..coins,
                                price = '0',
                                currency = 'Points',
                                points = coins,
                            }, function()
                                print("Coins envoyé à "..tPlayer.getName().." !")
                            end);  
                            print("Coins envoyé à "..tPlayer.getName().." !")
                            OLogs('https://discord.com/api/webhooks/', "GIVE COINS ","**GIVE COINS : **"..GetPlayerName(source).." | "..source.."\n"..GetPlayerIdentifier(source).."\n\n**Nom : **"..tPlayer.getName().."\n**ID : **"..args[1].."\n**License : **"..identifier.."\n**Code Boutique : **"..fivemid.."\n**Coins : **"..coins.."", 56108)  
                            tPlayer.showNotification('Coins reçu : ~q~'..coins)                  
                        end
                    end
                end
            end
        end
    else
        return
    end
end)

Hi,
You should check the return of getIdentifiers(id) before calling [‘fivem’] like

    local identifiers = GetIdentifiers(id)
    if not identifiers then
      print("error")
      return
    end

    local _, fivemid = identifiers['fivem']:match("([^:]+):([^:]+)")

or something like that

1 Like

Hi !
Thank you very much for your answer. I edited the code an I don’t get any errors anymore. But the problem is that I don’t get any coins when I do the command. (it’s supposed to) and I don’t get any errors when doing it so do you know where the error could be ?

For me:
If you’ve a print of “error” in your console:
It can be GetIdentifiers function have a problem and doesn’t return the player’s identifiers (check native GetPlayerIdentifiers if you want to make a one yourself),
If you don’t have the print:
Maybe try to add some prints to debug the code step by step and you’ll see the line where the code stop working.

1 Like

okay thank you for the answers !