-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.lua
360 lines (329 loc) · 13.7 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
WeaponNames = {
[tostring(GetHashKey('WEAPON_UNARMED'))] = 'Unarmed',
[tostring(GetHashKey('GADGET_PARACHUTE'))] = 'Parachute',
[tostring(GetHashKey('WEAPON_KNIFE'))] = 'Knife',
[tostring(GetHashKey('WEAPON_NIGHTSTICK'))] = 'Nightstick',
[tostring(GetHashKey('WEAPON_HAMMER'))] = 'Hammer',
[tostring(GetHashKey('WEAPON_BAT'))] = 'Baseball Bat',
[tostring(GetHashKey('WEAPON_CROWBAR'))] = 'Crowbar',
[tostring(GetHashKey('WEAPON_GOLFCLUB'))] = 'Golf Club',
[tostring(GetHashKey('WEAPON_BOTTLE'))] = 'Bottle',
[tostring(GetHashKey('WEAPON_DAGGER'))] = 'Antique Cavalry Dagger',
[tostring(GetHashKey('WEAPON_HATCHET'))] = 'Hatchet',
[tostring(GetHashKey('WEAPON_KNUCKLE'))] = 'Knuckle Duster',
[tostring(GetHashKey('WEAPON_MACHETE'))] = 'Machete',
[tostring(GetHashKey('WEAPON_FLASHLIGHT'))] = 'Flashlight',
[tostring(GetHashKey('WEAPON_SWITCHBLADE'))] = 'Switchblade',
[tostring(GetHashKey('WEAPON_BATTLEAXE'))] = 'Battleaxe',
[tostring(GetHashKey('WEAPON_POOLCUE'))] = 'Poolcue',
[tostring(GetHashKey('WEAPON_PIPEWRENCH'))] = 'Wrench',
[tostring(GetHashKey('WEAPON_STONE_HATCHET'))] = 'Stone Hatchet',
[tostring(GetHashKey('WEAPON_PISTOL'))] = 'Pistol',
[tostring(GetHashKey('WEAPON_PISTOL_MK2'))] = 'Pistol Mk2',
[tostring(GetHashKey('WEAPON_COMBATPISTOL'))] = 'Combat Pistol',
[tostring(GetHashKey('WEAPON_PISTOL50'))] = 'Pistol .50 ',
[tostring(GetHashKey('WEAPON_SNSPISTOL'))] = 'SNS Pistol',
[tostring(GetHashKey('WEAPON_SNSPISTOL_MK2'))] = 'SNS Pistol Mk2',
[tostring(GetHashKey('WEAPON_HEAVYPISTOL'))] = 'Heavy Pistol',
[tostring(GetHashKey('WEAPON_VINTAGEPISTOL'))] = 'Vintage Pistol',
[tostring(GetHashKey('WEAPON_MARKSMANPISTOL'))] = 'Marksman Pistol',
[tostring(GetHashKey('WEAPON_REVOLVER'))] = 'Heavy Revolver',
[tostring(GetHashKey('WEAPON_REVOLVER_MK2'))] = 'Heavy Revolver Mk2',
[tostring(GetHashKey('WEAPON_DOUBLEACTION'))] = 'Double-Action Revolver',
[tostring(GetHashKey('WEAPON_APPISTOL'))] = 'AP Pistol',
[tostring(GetHashKey('WEAPON_STUNGUN'))] = 'Stun Gun',
[tostring(GetHashKey('WEAPON_FLAREGUN'))] = 'Flare Gun',
[tostring(GetHashKey('WEAPON_RAYPISTOL'))] = 'Up-n-Atomizer',
[tostring(GetHashKey('WEAPON_MICROSMG'))] = 'Micro SMG',
[tostring(GetHashKey('WEAPON_MACHINEPISTOL'))] = 'Machine Pistol',
[tostring(GetHashKey('WEAPON_MINISMG'))] = 'Mini SMG',
[tostring(GetHashKey('WEAPON_SMG'))] = 'SMG',
[tostring(GetHashKey('WEAPON_SMG_MK2'))] = 'SMG Mk2 ',
[tostring(GetHashKey('WEAPON_ASSAULTSMG'))] = 'Assault SMG',
[tostring(GetHashKey('WEAPON_COMBATPDW'))] = 'Combat PDW',
[tostring(GetHashKey('WEAPON_MG'))] = 'MG',
[tostring(GetHashKey('WEAPON_COMBATMG'))] = 'Combat MG ',
[tostring(GetHashKey('WEAPON_COMBATMG_MK2'))] = 'Combat MG Mk2',
[tostring(GetHashKey('WEAPON_GUSENBERG'))] = 'Gusenberg Sweeper',
[tostring(GetHashKey('WEAPON_RAYCARBINE'))] = 'Unholy Deathbringer',
[tostring(GetHashKey('WEAPON_ASSAULTRIFLE'))] = 'Assault Rifle',
[tostring(GetHashKey('WEAPON_ASSAULTRIFLE_MK2'))] = 'Assault Rifle Mk2',
[tostring(GetHashKey('WEAPON_CARBINERIFLE'))] = 'Carbine Rifle',
[tostring(GetHashKey('WEAPON_CARBINERIFLE_MK2'))] = 'Carbine Rifle Mk2',
[tostring(GetHashKey('WEAPON_ADVANCEDRIFLE'))] = 'Advanced Rifle',
[tostring(GetHashKey('WEAPON_SPECIALCARBINE'))] = 'Special Carbine',
[tostring(GetHashKey('WEAPON_SPECIALCARBINE_MK2'))] = 'Special Carbine Mk2',
[tostring(GetHashKey('WEAPON_BULLPUPRIFLE'))] = 'Bullpup Rifle',
[tostring(GetHashKey('WEAPON_BULLPUPRIFLE_MK2'))] = 'Bullpup Rifle Mk2',
[tostring(GetHashKey('WEAPON_COMPACTRIFLE'))] = 'Compact Rifle',
[tostring(GetHashKey('WEAPON_SNIPERRIFLE'))] = 'Sniper Rifle',
[tostring(GetHashKey('WEAPON_HEAVYSNIPER'))] = 'Heavy Sniper',
[tostring(GetHashKey('WEAPON_HEAVYSNIPER_MK2'))] = 'Heavy Sniper Mk2',
[tostring(GetHashKey('WEAPON_MARKSMANRIFLE'))] = 'Marksman Rifle',
[tostring(GetHashKey('WEAPON_MARKSMANRIFLE_MK2'))] = 'Marksman Rifle Mk2',
[tostring(GetHashKey('WEAPON_GRENADE'))] = 'Grenade',
[tostring(GetHashKey('WEAPON_STICKYBOMB'))] = 'Sticky Bomb',
[tostring(GetHashKey('WEAPON_PROXMINE'))] = 'Proximity Mine',
[tostring(GetHashKey('WAPAON_PIPEBOMB'))] = 'Pipe Bomb',
[tostring(GetHashKey('WEAPON_SMOKEGRENADE'))] = 'Tear Gas',
[tostring(GetHashKey('WEAPON_BZGAS'))] = 'BZ Gas',
[tostring(GetHashKey('WEAPON_MOLOTOV'))] = 'Molotov',
[tostring(GetHashKey('WEAPON_FIREEXTINGUISHER'))] = 'Fire Extinguisher',
[tostring(GetHashKey('WEAPON_PETROLCAN'))] = 'Jerry Can',
[tostring(GetHashKey('WEAPON_BALL'))] = 'Ball',
[tostring(GetHashKey('WEAPON_SNOWBALL'))] = 'Snowball',
[tostring(GetHashKey('WEAPON_FLARE'))] = 'Flare',
[tostring(GetHashKey('WEAPON_GRENADELAUNCHER'))] = 'Grenade Launcher',
[tostring(GetHashKey('WEAPON_RPG'))] = 'RPG',
[tostring(GetHashKey('WEAPON_MINIGUN'))] = 'Minigun',
[tostring(GetHashKey('WEAPON_FIREWORK'))] = 'Firework Launcher',
[tostring(GetHashKey('WEAPON_RAILGUN'))] = 'Railgun',
[tostring(GetHashKey('WEAPON_HOMINGLAUNCHER'))] = 'Homing Launcher',
[tostring(GetHashKey('WEAPON_COMPACTLAUNCHER'))] = 'Compact Grenade Launcher',
[tostring(GetHashKey('WEAPON_RAYMINIGUN'))] = 'Widowmaker',
[tostring(GetHashKey('WEAPON_PUMPSHOTGUN'))] = 'Pump Shotgun',
[tostring(GetHashKey('WEAPON_PUMPSHOTGUN_MK2'))] = 'Pump Shotgun Mk2',
[tostring(GetHashKey('WEAPON_SAWNOFFSHOTGUN'))] = 'Sawed-off Shotgun',
[tostring(GetHashKey('WEAPON_BULLPUPSHOTGUN'))] = 'Bullpup Shotgun',
[tostring(GetHashKey('WEAPON_ASSAULTSHOTGUN'))] = 'Assault Shotgun',
[tostring(GetHashKey('WEAPON_MUSKET'))] = 'Musket',
[tostring(GetHashKey('WEAPON_HEAVYSHOTGUN'))] = 'Heavy Shotgun',
[tostring(GetHashKey('WEAPON_DBSHOTGUN'))] = 'Double Barrel Shotgun',
[tostring(GetHashKey('WEAPON_SWEEPERSHOTGUN'))] = 'Sweeper Shotgun',
[tostring(GetHashKey('WEAPON_REMOTESNIPER'))] = 'Remote Sniper',
[tostring(GetHashKey('WEAPON_GRENADELAUNCHER_SMOKE'))] = 'Smoke Grenade Launcher',
[tostring(GetHashKey('WEAPON_PASSENGER_ROCKET'))] = 'Passenger Rocket',
[tostring(GetHashKey('WEAPON_AIRSTRIKE_ROCKET'))] = 'Airstrike Rocket',
[tostring(GetHashKey('WEAPON_STINGER'))] = 'Stinger [Vehicle]',
[tostring(GetHashKey('OBJECT'))] = 'Object',
[tostring(GetHashKey('VEHICLE_WEAPON_TANK'))] = 'Tank Cannon',
[tostring(GetHashKey('VEHICLE_WEAPON_SPACE_ROCKET'))] = 'Rockets',
[tostring(GetHashKey('VEHICLE_WEAPON_PLAYER_LASER'))] = 'Laser',
[tostring(GetHashKey('AMMO_RPG'))] = 'Rocket',
[tostring(GetHashKey('AMMO_TANK'))] = 'Tank',
[tostring(GetHashKey('AMMO_SPACE_ROCKET'))] = 'Rocket',
[tostring(GetHashKey('AMMO_PLAYER_LASER'))] = 'Laser',
[tostring(GetHashKey('AMMO_ENEMY_LASER'))] = 'Laser',
[tostring(GetHashKey('WEAPON_RAMMED_BY_CAR'))] = 'Rammed by Car',
[tostring(GetHashKey('WEAPON_FIRE'))] = 'Fire',
[tostring(GetHashKey('WEAPON_HELI_CRASH'))] = 'Heli Crash',
[tostring(GetHashKey('WEAPON_RUN_OVER_BY_CAR'))] = 'Run over by Car',
[tostring(GetHashKey('WEAPON_HIT_BY_WATER_CANNON'))] = 'Hit by Water Cannon',
[tostring(GetHashKey('WEAPON_EXHAUSTION'))] = 'Exhaustion',
[tostring(GetHashKey('WEAPON_EXPLOSION'))] = 'Explosion',
[tostring(GetHashKey('WEAPON_ELECTRIC_FENCE'))] = 'Electric Fence',
[tostring(GetHashKey('WEAPON_BLEEDING'))] = 'Bleeding',
[tostring(GetHashKey('WEAPON_DROWNING_IN_VEHICLE'))] = 'Drowning in Vehicle',
[tostring(GetHashKey('WEAPON_DROWNING'))] = 'Drowning',
[tostring(GetHashKey('WEAPON_BARBED_WIRE'))] = 'Barbed Wire',
[tostring(GetHashKey('WEAPON_VEHICLE_ROCKET'))] = 'Vehicle Rocket',
[tostring(GetHashKey('VEHICLE_WEAPON_ROTORS'))] = 'Rotors',
[tostring(GetHashKey('WEAPON_AIR_DEFENCE_GUN'))] = 'Air Defence Gun',
[tostring(GetHashKey('WEAPON_ANIMAL'))] = 'Animal',
[tostring(GetHashKey('WEAPON_COUGAR'))] = 'Cougar'
}
Citizen.CreateThread(function()
local DeathReason, Killer, DeathCauseHash, Weapon
while true do
Citizen.Wait(0)
if IsEntityDead(GetPlayerPed(PlayerId())) then
Citizen.Wait(0)
local PedKiller = GetPedSourceOfDeath(GetPlayerPed(PlayerId()))
local killername = GetPlayerName(PedKiller)
DeathCauseHash = GetPedCauseOfDeath(GetPlayerPed(PlayerId()))
Weapon = WeaponNames[tostring(DeathCauseHash)]
if IsEntityAPed(PedKiller) and IsPedAPlayer(PedKiller) then
Killer = NetworkGetPlayerIndexFromPed(PedKiller)
elseif IsEntityAVehicle(PedKiller) and IsEntityAPed(GetPedInVehicleSeat(PedKiller, -1)) and IsPedAPlayer(GetPedInVehicleSeat(PedKiller, -1)) then
Killer = NetworkGetPlayerIndexFromPed(GetPedInVehicleSeat(PedKiller, -1))
end
if (Killer == PlayerId()) then
DeathReason = 'committed suicide'
elseif (Killer == nil) then
DeathReason = 'died'
else
if IsMelee(DeathCauseHash) then
DeathReason = 'murdered'
elseif IsTorch(DeathCauseHash) then
DeathReason = 'torched'
elseif IsKnife(DeathCauseHash) then
DeathReason = 'knifed'
elseif IsPistol(DeathCauseHash) then
DeathReason = 'pistoled'
elseif IsSub(DeathCauseHash) then
DeathReason = 'riddled'
elseif IsRifle(DeathCauseHash) then
DeathReason = 'rifled'
elseif IsLight(DeathCauseHash) then
DeathReason = 'machine gunned'
elseif IsShotgun(DeathCauseHash) then
DeathReason = 'pulverized'
elseif IsSniper(DeathCauseHash) then
DeathReason = 'sniped'
elseif IsHeavy(DeathCauseHash) then
DeathReason = 'obliterated'
elseif IsMinigun(DeathCauseHash) then
DeathReason = 'shredded'
elseif IsBomb(DeathCauseHash) then
DeathReason = 'bombed'
elseif IsVeh(DeathCauseHash) then
DeathReason = 'mowed over'
elseif IsVK(DeathCauseHash) then
DeathReason = 'flattened'
else
DeathReason = 'killed'
end
end
if DeathReason == 'committed suicide' or DeathReason == 'died' then
TriggerServerEvent('playerDied',1,GetPlayerServerId(PlayerId()),0,DeathReason,Weapon)
else
TriggerServerEvent('playerDied',2,GetPlayerServerId(PlayerId()),GetPlayerServerId(Killer),DeathReason,Weapon)
end
Killer = nil
DeathReason = nil
DeathCauseHash = nil
Weapon = nil
end
while IsEntityDead(PlayerPedId()) do
Citizen.Wait(0)
end
end
end)
function hashToWeapon(hash)
return weapons[hash]
end
exports('discord', function(message, id, id2, color, channel)
TriggerServerEvent('ClientDiscord', message, id, id2, color, channel)
end)
function IsMelee(Weapon)
local Weapons = {'WEAPON_UNARMED', 'WEAPON_CROWBAR', 'WEAPON_BAT', 'WEAPON_GOLFCLUB', 'WEAPON_HAMMER', 'WEAPON_NIGHTSTICK'}
for i, CurrentWeapon in ipairs(Weapons) do
if GetHashKey(CurrentWeapon) == Weapon then
return true
end
end
return false
end
function IsTorch(Weapon)
local Weapons = {'WEAPON_MOLOTOV'}
for i, CurrentWeapon in ipairs(Weapons) do
if GetHashKey(CurrentWeapon) == Weapon then
return true
end
end
return false
end
function IsKnife(Weapon)
local Weapons = {'WEAPON_DAGGER', 'WEAPON_KNIFE', 'WEAPON_SWITCHBLADE', 'WEAPON_HATCHET', 'WEAPON_BOTTLE'}
for i, CurrentWeapon in ipairs(Weapons) do
if GetHashKey(CurrentWeapon) == Weapon then
return true
end
end
return false
end
function IsPistol(Weapon)
local Weapons = {'WEAPON_SNSPISTOL', 'WEAPON_HEAVYPISTOL', 'WEAPON_VINTAGEPISTOL', 'WEAPON_PISTOL', 'WEAPON_APPISTOL', 'WEAPON_COMBATPISTOL'}
for i, CurrentWeapon in ipairs(Weapons) do
if GetHashKey(CurrentWeapon) == Weapon then
return true
end
end
return false
end
function IsSub(Weapon)
local Weapons = {'WEAPON_MICROSMG', 'WEAPON_SMG'}
for i, CurrentWeapon in ipairs(Weapons) do
if GetHashKey(CurrentWeapon) == Weapon then
return true
end
end
return false
end
function IsRifle(Weapon)
local Weapons = {'WEAPON_CARBINERIFLE', 'WEAPON_MUSKET', 'WEAPON_ADVANCEDRIFLE', 'WEAPON_ASSAULTRIFLE', 'WEAPON_SPECIALCARBINE', 'WEAPON_COMPACTRIFLE', 'WEAPON_BULLPUPRIFLE'}
for i, CurrentWeapon in ipairs(Weapons) do
if GetHashKey(CurrentWeapon) == Weapon then
return true
end
end
return false
end
function IsLight(Weapon)
local Weapons = {'WEAPON_MG', 'WEAPON_COMBATMG'}
for i, CurrentWeapon in ipairs(Weapons) do
if GetHashKey(CurrentWeapon) == Weapon then
return true
end
end
return false
end
function IsShotgun(Weapon)
local Weapons = {'WEAPON_BULLPUPSHOTGUN', 'WEAPON_ASSAULTSHOTGUN', 'WEAPON_DBSHOTGUN', 'WEAPON_PUMPSHOTGUN', 'WEAPON_HEAVYSHOTGUN', 'WEAPON_SAWNOFFSHOTGUN'}
for i, CurrentWeapon in ipairs(Weapons) do
if GetHashKey(CurrentWeapon) == Weapon then
return true
end
end
return false
end
function IsSniper(Weapon)
local Weapons = {'WEAPON_MARKSMANRIFLE', 'WEAPON_SNIPERRIFLE', 'WEAPON_HEAVYSNIPER', 'WEAPON_ASSAULTSNIPER', 'WEAPON_REMOTESNIPER'}
for i, CurrentWeapon in ipairs(Weapons) do
if GetHashKey(CurrentWeapon) == Weapon then
return true
end
end
return false
end
function IsHeavy(Weapon)
local Weapons = {'WEAPON_GRENADELAUNCHER', 'WEAPON_RPG', 'WEAPON_FLAREGUN', 'WEAPON_HOMINGLAUNCHER', 'WEAPON_FIREWORK', 'VEHICLE_WEAPON_TANK'}
for i, CurrentWeapon in ipairs(Weapons) do
if GetHashKey(CurrentWeapon) == Weapon then
return true
end
end
return false
end
function IsMinigun(Weapon)
local Weapons = {'WEAPON_MINIGUN'}
for i, CurrentWeapon in ipairs(Weapons) do
if GetHashKey(CurrentWeapon) == Weapon then
return true
end
end
return false
end
function IsBomb(Weapon)
local Weapons = {'WEAPON_GRENADE', 'WEAPON_PROXMINE', 'WEAPON_EXPLOSION', 'WEAPON_STICKYBOMB'}
for i, CurrentWeapon in ipairs(Weapons) do
if GetHashKey(CurrentWeapon) == Weapon then
return true
end
end
return false
end
function IsVeh(Weapon)
local Weapons = {'VEHICLE_WEAPON_ROTORS'}
for i, CurrentWeapon in ipairs(Weapons) do
if GetHashKey(CurrentWeapon) == Weapon then
return true
end
end
return false
end
function IsVK(Weapon)
local Weapons = {'WEAPON_RUN_OVER_BY_CAR', 'WEAPON_RAMMED_BY_CAR'}
for i, CurrentWeapon in ipairs(Weapons) do
if GetHashKey(CurrentWeapon) == Weapon then
return true
end
end
return false
end
--Debug shizzels :D
function ShowDebug(text)
SetNotificationTextEntry("STRING")
AddTextComponentSubstringPlayerName("~b~JD_logs Debug:~s~\n"..text)
DrawNotification(true, true)
end