I would like to save player endpoint to my database…
because of all the player using mod menu that come and leave before we can ban them and all of the script that handle the ban need the ip…

I did a little code but it doesn’t seem to work… if anyone can help

RegisterServerEvent('updateIPadress')
AddEventHandler('updateIPadress', function()
  local xPlayer        = ESX.GetPlayerFromId(source)
  local endpoint = GetPlayerEndpoint(source)
  print("IPAdress - updated "..tostring(GetPlayerEndpoint(source)).." sur "..xPlayer.identifier)

  MySQL.Async.execute(
        'UPDATE users SET endpoint = '..endpoint..' WHERE identifier = @identifier',
        {
          ['@identifier'] = xPlayer.identifier,
        },
        function()
        end)
end)

Any errors?

Try to add

local _source = source

and replace all the existing source with _source.

i don’t need to add that, since source is calling the player.
As you can see in the picture, it detect my ip and show it : 127.0.0.1 but it seem that in the mysql line:

’UPDATE users SET endpoint = ‘…endpoint…’ WHERE identifier = @identifier’,
it break the code after the 127.0.

Ok, Try

MySQL.Async.execute(
        'UPDATE users SET endpoint = @endpoint WHERE identifier = @identifier',
        {
          ['@identifier'] = xPlayer.identifier,
          ['@enpoint'] = endpoint
        },
        function()
        end)
1 Like

There is no more error, but it not updating anything in the database

It working now, thanks you
you just mispelled [‘@endpoint’] = endpoint

Everything fine now :smiley:

oh lol