Try with that :

local function OnPlayerConnecting(name, setKickReason, deferrals)
  local Source = source  
  MySQL.ready(function()
    local steamID = nil
    local identifiers = GetPlayerIdentifiers(Source)

    print("Source: " .. source)

    for _, v in pairs(identifiers) do
      if string.find(v, "steam") then
        steamID = v
        break
      end
    end

    local result = MySQL.Sync.fetchAll("SELECT * FROM `users` WHERE `identifier`=@steam", {['steam'] = steamID})
    if result then
      TriggerClientEvent("mysqlTest:test", Source, result)
    end
  end)
end``

With sync mysql same error
Already restarted the game client and the game server

local function OnPlayerConnecting(name, setKickReason, deferrals)
	local steamID = nil
	local identifiers = GetPlayerIdentifiers(source)
	
	print("Source: " .. source)
	
	--Steam identifier
	for _, v in pairs(identifiers) do
        if string.find(v, "steam") then
            steamID = v
            break
		end
    end
	
	local players = MySQL.Sync.fetchAll('SELECT id, name FROM users')
	print(players[1].id)
	TriggerClientEvent("mysqlTest:test", source, "test", "test")
end

AddEventHandler("playerConnecting", OnPlayerConnecting)
cfx> Connecting: MinePuzza
InvokeNative: execution failed: Argument at index 0 was null.
Error resuming coroutine: Execution of native 00000000ff7f66ab in script host failed.
stack traceback:
        [C]: in upvalue '_in'
        citizen:/scripting/lua/natives_server.lua:169: in function 'GetNumPlayerIdentifiers'
        citizen:/scripting/lua/scheduler.lua:244: in function 'GetPlayerIdentifiers'
        @mysqlTest/server.lua:4: in upvalue 'callback'
        @mysql-async/lib/MySQL.lua:197: in function <@mysql-async/lib/MySQL.lua:189>

This message principally appear when

source

have a nil value

No errors in console but same error

No in client console, check in server console

Nothing special in console

Wait, i will do tests in my server, i will give you the code after, give me 10 minutes

Thanks man, if you help me to resolve i’ll pay u:rofl::rofl:

AddEventHandler('playerConnecting', function(name, setKickReason)
  local identifier
  local Source = source
  for k,v in ipairs(GetPlayerIdentifiers(source))do
    if string.sub(v, 1, string.len("steam:")) == "steam:" then
      identifier = v
      break
    end
  end

  MySQL.ready(function()
    local result = MySQL.Sync.fetchAll("SELECT * FROM `users` WHERE `identifier`=@steam", {['steam'] = identifier})
    if result then
     TriggerClientEvent("mysqlTest:test", Source, result)
   end
 end)
end)

Worked !

You can add to be sure that user is connected to Steam and has connected before FiveM launching app

if not identifier then
    setKickReason("Steam ID not detected, please restart FiveM")
    CancelEvent()
  end

i can’t understand… still not work on my server…
can you please upload into internet the files and send to me link so i can directly download your code?

What is error code ?

same error. Job variable is not defined.

Don’t forget to print value in MySQL query and print the identifier variable first

After, check if a parameter is passed here, and your event goes here.
Proceed by step !

RegisterNetEvent("mysqlTest:test")
AddEventHandler("mysqlTest:test", function(par1, par2)
	print ("OK")
        print (par1, par2)
    job = par1
end)

i tryed to add in server.lua
print("Source: " .. source)
My friend and I joined the server and in the console we read “Source: 65536” and “Source: 65537”.
All ok.
I tryed to add in client.lua into the RegisterCommand function
print("Source: " .. source)
but when i do /test and i open console with F8 i can see “Source: 0” for me and the same “Source: 0” for my friend.
So i think this is the error. But it has no sense that two people have the same source. No?

No, no, Client / Server are not the same. In client, if you see the message in your client console, it is because you have received the message. (Server say to specific client (you) to do an action ) So, in client, to get your client player id , it is GetPlayerPed(-1). But, you don’t need this information. Have you checked in client that you receive your parameters ?

I added

print ("OK")
print (par1, par2)

And nothing changed. I didn’t see either of the two prints.
So i tryed to create a new event in client.lua. I added

local hello
RegisterNetEvent("hello1234")
AddEventHandler("hello1234", function(eventParam1, eventParam2)
	hello = "Woooooooooow"
end)

RegisterCommand("hello", function(source, args, rawCommand)
	TriggerEvent('chat:addMessage', {
		args = { "Madonna : " .. hello}
	})
end, false)

And I added in server.lua
TriggerClientEvent("ciaoneBurlone", "-1", "ciao", 21)
Where “-1” means all the client. So if i do /hello i can see “Madonna: Woooooow”

So I think that the problem is the “source” parameter in server script