Simple help - cant Trigger client event


#1

Hey! I have been trying to create a script to prevent people to disconect after they die to respawn alive. Its really simple, when a player dies, it saves into the database their identifier. When player load back again in the server, it checks if the payer was dead in database.
I only have one problem, I cant figure out why the script is not doing the ClientEvent killDCplayer

RegisterNetEvent('killDCplayer')
AddEventHandler('killDCplayer', function()
	SetEntityHealth(GetPlayerPed(-1), 0)
        print("inside killDCplayer")
end)
RegisterServerEvent('esx_ambulance:check')
AddEventHandler('esx_ambulance:check', function()
  local identifier = GetPlayerIdentifiers(source)[1]
  local executed_query = MySQL.Sync.fetchAll("SELECT * FROM dead_players WHERE identifier = @identifier", {
    ['@identifier'] = identifier
  })

    local isPlayerDead      = executed_query[1]
    if isPlayerDead ~= nil then
      local isDead     = tonumber(isPlayerDead['dead'])
      if isDead == 1 then
	TriggerClientEvent("killDCplayer", source)
        print("kill player") //should kill player
      end
    end

end)

Everything is working, put dead player in database, remove dead players from database, the only problems is to kill the player when he is dead in database.
Its a simple problem (I think), I just cant find where the problem is. Thanks for your help


#2

they did it ?
I am also looking for a script
for database
that the player feels dead
when he presses old f4