[Help] source GetPlayerIdentifiers is bug?

Hello

After disconnecting the source id and identifiers and completely bugged

How I could do to identify player and with a valid source id

mysql code

MySqlTEST()

RegisterServerEvent("PlayerFirstSpawned")
RegisterServerEvent("SalaryUpdateServer")

local IdentifiersList = {}

function ContainIdentifiers(NamePlayer)
    for i=1,#IdentifiersList do
        print(IdentifiersList[i].NamePlayer .. ":" .. IdentifiersList[i].Identifiers)
        if IdentifiersList[i].NamePlayer == NamePlayer then
           return IdentifiersList[i].Identifiers
        end
    end
    return "false"
end

AddEventHandler("SalaryUpdateServer", function()

       local Player = GetPlayers()[source]
       local Name = GetPlayerName(Player)
       
       local Identifiers = ContainIdentifiers(Name)

       print("Identifiers :" .. Identifiers)

       local infos = GetplayerMySql(Identifiers)

       infos.Money = infos.Money + 50
       UpdatePlayerMoneyMySql(infos)

       TriggerClientEvent("SalaryUpdate", Player, 50, infos)
end)

AddEventHandler("PlayerFirstSpawned", function(PlayerName)
   print("--------------------- PlayerFirstSpawned ---------------------")
   print("Source :" .. source)

   -- info gta
   local Player = GetPlayers()[source]

   print("PlayerName :" .. PlayerName)

   local Identifiers = ContainIdentifiers(PlayerName)
   print("Contain :" .. Identifiers)
   if Identifiers == "false" then
      local iden = GetPlayerIdentifiers(Player)
      Identifiers = "" .. table.concat(iden,  ", " )
      print("concat Identifiers: " .. Identifiers)
      local data = {NamePlayer = PlayerName, Identifiers = Identifiers}
      table.insert(IdentifiersList, data)
      print("table.insert : " .. PlayerName)
   end

   -- info mysql
   local infos = GetplayerMySql(Identifiers)
   if infos then 
        print("infos PlayerName : " .. infos.PlayerName)
       
        TriggerClientEvent("LoadPlayerData", Player, infos)
        CancelEvent()
   else
        local data = {PlayerName = PlayerName, Identifiers = Identifiers}
        AddPlayerMySql(data)
        infos = GetplayerMySql(Identifiers)
        
        TriggerClientEvent("LoadPlayerData", Player, infos)
        CancelEvent()
   end
end)

AddEventHandler("playerDropped", function(Reason)
    print("--------------------- playerDropped ---------------------")
    print("Source :" .. source)
end)

1 Like

Use steam as an identifier.

No longer works after a disconnection

local Player = GetPlayers()[source]

You need to store player data in a database. Look at kanersps’ essential mode script.

The question does not come from the database but from all symponly problem with the source id of the player who does not return the event is that Identifiers return not steam just an ip

Client connect very well. But after a disconnection and reconnexion everything goes wrong for the events

essential mode use TriggerEvent not TriggerClientEvent

dont call TriggerClientEvent and dont use source id

ok ok I know how to fix

Even this function after a disconnection it does not work …

function TriggerAllEvent(name, ...)
     for i=1,#GetPlayers() do
        print("---->" .. GetPlayerName(i))
        TriggerClientEvent(name, i,  ...)
     end
end

I have figured out that GetPlayers () is bug not used