-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.lua
71 lines (55 loc) · 3.07 KB
/
client.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
-- esx onPlayerDeath reimplementation
if Config.Framework ~= "esx" then
local PlayerKilledByPlayer = function(killerServerId, killerClientId, deathCause)
local victimCoords = GetEntityCoords(PlayerPedId())
local killerCoords = GetEntityCoords(GetPlayerPed(killerClientId))
local distance = #(victimCoords - killerCoords)
local data = {
victimCoords = victimCoords,
killerCoords = killerCoords,
killedByPlayer = true,
deathCause = deathCause,
distance = distance,
killerServerId = killerServerId,
killerClientId = killerClientId
}
return data
end
local PlayerKilled = function(deathCause)
local playerPed = PlayerPedId()
local victimCoords = GetEntityCoords(playerPed)
local data = {
victimCoords = victimCoords,
killedByPlayer = false,
deathCause = deathCause
}
return data
end
AddEventHandler("gameEventTriggered", function(event, data)
--[[
ESX-legacy - ESX framework for FiveM
Copyright (C) 2015-2023 ESX-Framework
This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version.
This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details.
You should have received a copy Of the GNU General Public License along with this program. If Not, see http://www.gnu.org/licenses/.
]]
if event ~= 'CEventNetworkEntityDamage' then return end
local victim, victimDied = data[1], data[4]
if not IsPedAPlayer(victim) then return end
local player = PlayerId()
local playerPed = PlayerPedId()
if victimDied and NetworkGetPlayerIndexFromPed(victim) == player and (IsPedDeadOrDying(victim, true) or IsPedFatallyInjured(victim)) then
local killerEntity, deathCause = GetPedSourceOfDeath(playerPed), GetPedCauseOfDeath(playerPed)
local killerClientId = NetworkGetPlayerIndexFromPed(killerEntity)
if killerEntity ~= playerPed and killerClientId and NetworkIsPlayerActive(killerClientId) then
local data = PlayerKilledByPlayer(GetPlayerServerId(killerClientId), killerClientId, deathCause)
TriggerEvent("utility_wrapper:esx:onPlayerDeath", data)
TriggerServerEvent("utility_wrapper:esx:onPlayerDeath", data)
else
local data = PlayerKilled(deathCause)
TriggerEvent("utility_wrapper:esx:onPlayerDeath", data)
TriggerServerEvent("utility_wrapper:esx:onPlayerDeath", data)
end
end
end)
end