Here is some code I used to solve the problem.
I dont remember some eventnames and now I use a resource scrambler, that’s why I quoted them with **.
Maybe this will help some, to workaround the problem.
server.lua
RegisterServerEvent('DelegateCorruptionCheck')
AddEventHandler('DelegateCorruptionCheck', function()
TriggerClientEvent('FirstSpawnCheckForCorruptedSession',-1)
end)
local checkedarray = {}
RegisterServerEvent('kickplayerbecausesessioniscorrupted')
AddEventHandler('kickplayerbecausesessioniscorrupted', function(id)
table.insert(checkedarray, {id = id, source = source, counter = 1 })
for i=1, #checkedarray,1 do
if checkedarray[i].id == id and checkedarray[i].source ~= source and checkedarray[i].counter > 3 then -- Cheater prevention
DropPlayer(id,'Player Zero problem: please restart FiveM!')
table.remove(checkedarray,i)
elseif checkedarray[i].id == id and checkedarray[i].source ~= source and checkedarray[i].counter <= 3 then
checkedarray[i].counter = checkedarray[i].counter + 1
end
end
end)
client.lua
RegisterNetEvent('FirstSpawnCheckForCorruptedSession')
AddEventHandler('FirstSpawnCheckForCorruptedSession', function()
Citizen.Wait(math.random(4500,19999))
ESX.TriggerServerCallback('*A method to get all players in the "players" array*', function(players)
for i=1, #players, 1 do
local id = GetPlayerFromServerId(players[i].source)
local ent = GetPlayerPed(id)
if ent ~= nil and GetEntityModel(ent) == 225514697 then -- check for "Michael" ped
TriggerServerEvent("kickplayerbecausesessioniscorrupted",players[i].source)
end
Citizen.Wait(15)
end
end)
end)
client.lua - in a first spawn script
RegisterNetEvent('*A SPAWN EVENT like esx:kashacters CharacterChosen or something*')
AddEventHandler('*A SPAWN EVENT like esx:kashacters CharacterChosen or something*', function()
Citizen.Wait(15000) -- give it some time to spawn the right char (if you use kashacters)
TriggerServerEvent("DelegateCorruptionCheck") -- CheckForSessionCorruption
end)