diff --git a/client/main.lua b/client/main.lua index 51f79c65..626c8746 100644 --- a/client/main.lua +++ b/client/main.lua @@ -104,9 +104,18 @@ AddEventHandler('baseevents:onPlayerKilled', function(killerPed, data) deathCause = GetPedCauseOfDeath(playerPed) }) - if killerPed ~= -1 then -- if the killer isn't AI + if killerPed == -1 then -- player died by AI, we cannot provide as much info because of baseevents setting 'killerPed' to '-1' + + table.insert(data, { + killed = false + }) + + else -- if the killer isn't AI + + killerPed = GetPlayerPed(GetPlayerFromServerId(killerPed)) local killerCoords = GetEntityCoords(killerPed) - local distance = GetDistanceBetweenCoords(table.unpack(killerCoords), table.unpack(data.victimCoords), false) + --local distance = GetDistanceBetweenCoords(table.unpack(killerCoords), table.unpack(data.victimCoords), false) + local distance = 2 table.insert(data, { killed = true, @@ -115,12 +124,6 @@ AddEventHandler('baseevents:onPlayerKilled', function(killerPed, data) distance = ESX.Round(distance) }) - else -- player died by AI, we cannot provide as much info because of baseevents setting 'killerPed' to '-1' - - table.insert(data, { - killed = false - }) - end TriggerEvent('esx:onPlayerDeath', data)