-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathserver.lua
852 lines (776 loc) · 32.3 KB
/
server.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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
ESX = nil
TriggerEvent("esx:getSharedObject", function(obj) ESX = obj end)
local ResourceMetadata = {}
local ResourceFiles = {}
---------------------------
-------- BAN BOOGERS ------
---------------------------
function banlistregenerator()
local o = LoadResourceFile(GetCurrentResourceName(), "ac-bans.json")
if not o or o == "" then
SaveResourceFile(GetCurrentResourceName(), "ac-bans.json", "[]", -1)
print("^"..math.random(1, 9).."^3Warning! ^0Your ^1ac-bans.json ^0is missing, Regenerating your ^1ac-bans.json ^0file!")
else
local p = json.decode(o)
if not p then
SaveResourceFile(GetCurrentResourceName(), "ac-bans.json", "[]", -1)
p = {}
print("^"..math.random(1, 9).."^3Warning! ^0Your ^1ac-bans.json ^0is corrupted, Regenerating your ^1ac-bans.json ^0file!")
end
end
end
function IsPlayerWhitelisted(playerId)
local identifiers = GetPlayerIdentifiers(playerId)
for _, id in pairs(identifiers) do
for _, whitelistedId in pairs(Config.WhitelistedPlayers) do
if id == whitelistedId then
return true
end
end
end
return false
end
function AntiCheatBans(source,reason)
local config = LoadResourceFile(GetCurrentResourceName(), "ac-bans.json")
local data = json.decode(config)
local _src = source
if config == nil then
banlistregenerator()
return
end
if GetPlayerName(_src) == nil then -- Make sure no any nil to come on our json.
return
end
local myid = GetIdentifier(_src);
local playerSteam = myid.steam;
local playerLicense = myid.license;
local playerXbl = myid.xbl;
local playerLive = myid.live;
local playerDiscord = myid.discord;
local banInfo = {};
--Identifiers.
banInfo['ID'] = tonumber(GetAndBanID());
banInfo['reason'] = reason;
banInfo['license'] = "No Info";
banInfo['steam'] = "No Info";
banInfo['xbl'] = "No Info";
banInfo['live'] = "No Info";
banInfo['discord'] = "No Info";
--Input to our json.
if playerLicense ~= nil and playerLicense ~= "nil" and playerLicense ~= "" then
banInfo['license'] = tostring(playerLicense);
end
if playerSteam ~= nil and playerSteam ~= "nil" and playerSteam ~= "" then
banInfo['steam'] = tostring(playerSteam);
end
if playerXbl ~= nil and playerXbl ~= "nil" and playerXbl ~= "" then
banInfo['xbl'] = tostring(playerXbl);
end
if playerLive ~= nil and playerLive ~= "nil" and playerLive ~= "" then
banInfo['live'] = tostring(playerXbl);
end
if playerDiscord ~= nil and playerDiscord ~= "nil" and playerDiscord ~= "" then
banInfo['discord'] = tostring(playerDiscord);
end
data[tostring(GetPlayerName(source))] = banInfo;
SaveResourceFile(GetCurrentResourceName(), "ac-bans.json", json.encode(data, { indent = true }), -1)
end
function GetIdentifier(source)
local identifiers = {
steam = "",
ip = "",
discord = "",
license = "",
xbl = "",
live = ""
}
for i = 0, GetNumPlayerIdentifiers(source) - 1 do
local id = GetPlayerIdentifier(source, i)
--Full to table
if string.find(id, "steam") then
identifiers.steam = id
elseif string.find(id, "ip") then
identifiers.ip = id
elseif string.find(id, "discord") then
identifiers.discord = id
elseif string.find(id, "license") then
identifiers.license = id
elseif string.find(id, "xbl") then
identifiers.xbl = id
elseif string.find(id, "live") then
identifiers.live = id
end
end
return identifiers
end
function GetAndBanID()
local config = LoadResourceFile(GetCurrentResourceName(), "ac-bans.json")
local data = json.decode(config)
local banID = 0;
for k, v in pairs(data) do
banID = banID + 1;
end
return (banID + 1);
end
function sendwebhooktodc(content)
local _source = source
local connect =
{
{
["color"] = "23295",
["title"] = "Rawe AntiCheat",
["description"] = "Player: "..GetPlayerName(_source).. " " ..GetPlayerIdentifiers(_source)[1].."", content,
["footer"] = {
["text"] = "github.com/RaweRwe/rw-anticheat",
},
}
}
PerformHttpRequest(Config.WebhookDiscord, function(err, text, headers) end, 'POST', json.encode({username = "RW-AC", embeds = connect}), { ['Content-Type'] = 'application/json' })
end
-- kickorbancheater(source,"Content Text", "Info Text",kick,ban) c = Kick d = Ban
-- Example use: kickorbancheater(_src,"Weapon Explosion Detected", "This Player tried to change bullet type",true,true)
function kickorbancheater(source,content,info,c,d)
local _source = source
local sname = GetPlayerName(_source)
--Identifiers
local steam = "unknown"
local discord = "unknown"
local license = "unknown"
local live = "unknown"
local xbl = "unknown"
if IsPlayerWhitelisted(_source) then
return
end
for m, n in ipairs(GetPlayerIdentifiers(_source)) do
if n:match("steam") then
steam = n
elseif n:match("discord") then
discord = n:gsub("discord:", "")
elseif n:match("license") then
license = n
elseif n:match("live") then
live = n
elseif n:match("xbl") then
xbl = n
end
end
local discordinfo = {
{
["color"] = "23295",
["title"] = "Rawe AntiCheat",
["description"] = "**Player: **"..sname.. "\n**ServerID:** ".._source.."\n**Violation:** "..content.."\n**Details:** "..info.."\n**Steam:** "..steam.."\n**License: **"..license.."\n**Xbl: **"..xbl.."\n**Live: **"..live.."\n**Discord**: <@"..discord..">",
["footer"] = {
["text"] = "github.com/RaweRwe/rw-anticheat " ..os.date("%c").. "",
},
}
}
PerformHttpRequest(Config.WebhookDiscord, function(err, text, headers) end, 'POST', json.encode({username = "RW-AC", embeds = discordinfo}), { ['Content-Type'] = 'application/json' })
if d then
AntiCheatBans(source,content)
end
if c then
DropPlayer(source, "Kicked : "..Config.DropMsg)
end
end
function OnPlayerConnecting(name, setKickReason, deferrals)
deferrals.defer();
local src = source;
local banned = false;
local ban = getBanned(src);
Citizen.Wait(100);
if ban then
-- They are banned
local reason = ban['reason'];
print("[BANNED PLAYER] Player " .. GetPlayerName(src) .. " tried to join, but was banned for: " .. reason);
deferrals.done("(BAN ID: " .. ban['banID'] .. ") " .. Config.ReasonBanned);
banned = true;
CancelEvent();
return;
end
if not banned then
deferrals.done();
end
end
function getBanned(source)
local config = LoadResourceFile(GetCurrentResourceName(), "ac-bans.json")
local data = json.decode(config)
if config == nil then
banlistregenerator()
return
end
local myid = GetIdentifier(source);
local playerSteam = myid.steam;
local playerLicense = myid.license;
local playerXbl = myid.xbl;
local playerLive = myid.live;
local playerDisc = myid.discord;
for k, bigData in pairs(data) do
local reason = bigData['reason']
local id = bigData['ID']
local license = bigData['license']
local steam = bigData['steam']
local xbl = bigData['xbl']
local live = bigData['live']
local discord = bigData['discord']
if tostring(license) == tostring(playerLicense) then return { ['banID'] = id, ['reason'] = reason } end;
if tostring(steam) == tostring(playerSteam) then return { ['banID'] = id, ['reason'] = reason } end;
if tostring(xbl) == tostring(playerXbl) then return { ['banID'] = id, ['reason'] = reason } end;
if tostring(live) == tostring(playerLive) then return { ['banID'] = id, ['reason'] = reason } end;
if tostring(discord) == tostring(playerDisc) then return { ['banID'] = id, ['reason'] = reason } end;
end
return false;
end
AddEventHandler("playerConnecting", OnPlayerConnecting)
RegisterCommand('ac-unban', function(source, args, rawCommand)
local src = source;
if (src <= 0) then
-- Console unban
if #args == 0 then
-- Not enough arguments
print('^3[^6RW-AntiCheat^3] ^1Not enough arguments...');
return;
end
local banID = args[1];
if tonumber(banID) ~= nil then
local playerName = UnbanPlayer(banID);
if playerName then
print('^3[^6RW-AntiCheat^3] ^0Player ^1' .. playerName
.. ' ^0has been unbanned from the server by ^2CONSOLE');
TriggerClientEvent('chatMessage', -1, '^3[^6RW-AntiCheat^3] ^0Player ^1' .. playerName
.. ' ^0has been unbanned from the server by ^2CONSOLE');
else
-- Not a valid ban ID
print('^3[^6RW-AntiCheat^3] ^1That is not a valid ban ID. No one has been unbanned!');
end
end
return;
end
if IsPlayerWhitelisted(src) then
if #args == 0 then
-- Not enough arguments
TriggerClientEvent('chatMessage', src, '^3[^6RW-AntiCheat^3] ^1Not enough arguments...');
return;
end
local banID = args[1];
if tonumber(banID) ~= nil then
-- Is a valid ban ID
local playerName = UnbanPlayer(banID);
if playerName then
TriggerClientEvent('chatMessage', -1, '^3[^6RW-AntiCheat^3] ^0Player ^1' .. playerName
.. ' ^0has been unbanned from the server by ^2' .. GetPlayerName(src));
else
-- Not a valid ban ID
TriggerClientEvent('chatMessage', src, '^3[^6RW-AntiCheat^3] ^1That is not a valid ban ID. No one has been unbanned!');
end
else
-- Not a valid number
TriggerClientEvent('chatMessage', src, '^3[^6RW-AntiCheat^3] ^1That is not a valid number...');
end
else
TriggerClientEvent('chatMessage', src, '^3[^6RW-AntiCheat^3] ^1You do not have permission to use this command.');
end
end
end)
function UnbanPlayer(banID)
local config = LoadResourceFile(GetCurrentResourceName(), "ac-bans.json")
local cfg = json.decode(config)
for k, v in pairs(cfg) do
local id = tonumber(v['ID']);
if id == tonumber(banID) then
local name = k;
cfg[k] = nil;
SaveResourceFile(GetCurrentResourceName(), "ac-bans.json", json.encode(cfg, { indent = true }), -1)
return name;
end
end
return false;
end
-- /acban command
RegisterCommand("ac-ban", function(source, args, raw) -- /acban <id> <reason>
local src = source;
-- Check if the command is run from console
if src <= 0 then
-- Console command execution
if #args < 2 then
-- Not enough arguments
print("^5[^1RW-AntiCheat^5] ^1ERROR: You have supplied invalid amount of arguments... " ..
"^2Proper Usage: /acban <id> <reason>")
return
end
local id = args[1]
local playerIdentifiers = GetIdentifier(id)
if playerIdentifiers ~= nil then
-- Valid player ID
local reason = table.concat(args, ' '):gsub(id .. " ", "")
AntiCheatBans(id, reason)
print("^5[^1RW-AntiCheat^5] ^0Player ^1" .. id .. " ^0has been banned by ^2CONSOLE")
else
-- Invalid player ID
print("^5[^1RW-AntiCheat^5] ^1ERROR: There is no valid player with that ID online... " ..
"^2Proper Usage: /acban <id> <reason>")
end
return
end
-- Whitelist check
if IsPlayerWhitelisted(src) then
if #args < 2 then
-- Not enough arguments
TriggerClientEvent('chatMessage', source, "^5[^1RW-AntiCheat^5] ^1ERROR: You have supplied invalid amount of arguments... " ..
"^2Proper Usage: /acban <id> <reason>")
return
end
local id = args[1]
local playerIdentifiers = GetIdentifier(id)
if playerIdentifiers ~= nil then
-- Valid player ID
local reason = table.concat(args, ' '):gsub(id .. " ", "")
AntiCheatBans(id, reason)
TriggerClientEvent('chatMessage', -1, "^5[^1RW-AntiCheat^5] ^0Player ^1" .. id ..
" ^0has been banned by ^2" .. GetPlayerName(src))
else
-- Invalid player ID
TriggerClientEvent('chatMessage', source, "^5[^1RW-AntiCheat^5] ^1ERROR: There is no valid player with that ID online... " ..
"^2Proper Usage: /acban <id> <reason>")
end
else
-- If not whitelisted
TriggerClientEvent('chatMessage', src, '^5[^1RW-AntiCheat^5] ^1ERROR: You do not have permission to use this command.')
end
end)
-----
RegisterServerEvent("8jWpZudyvjkDXQ2RVXf9")
AddEventHandler("8jWpZudyvjkDXQ2RVXf9", function(type)
local _type = type or "default"
local _src = source
local _item = item or "none"
local _name = GetPlayerName(_src)
_type = string.lower(_type)
if (_type == "invisible") then
kickorbancheater(_src,"Tried to be Invisible", "This Player tried to Invisible",true,true)
elseif (_type == "antiragdoll") then
kickorbancheater(_src,"AntiRagdoll Detected", "This Player tried to activate Anti-Ragdoll",true,true)
elseif (_type == "displayradar") then
kickorbancheater(_src,"Radar Detected", "This Player tried to activate Radar",true,true)
elseif (_type == "explosiveweapon") then
kickorbancheater(_src,"Weapon Explosion Detected", "This Player tried to change bullet type",true,true)
elseif (_type == "spectatormode") then
kickorbancheater(_src,"Spectate Detected", "This Player tried to Spectate a Player",true,true)
elseif (_type == "speedhack") then
kickorbancheater(_src,"SpeedHack Detected", "This Player tried to SpeedHack",true,true)
elseif (_type == "blacklistedweapons") then
kickorbancheater(_src,"Weapon in Blacklist", "This Player tried to spawn a Blacklisted Weapon",true,true)
elseif (_type == "thermalvision") then
kickorbancheater(_src,"Thermal Camera Detected", "This Player tried to use Thermal Camera",true,true)
elseif (_type == "nightvision") then
kickorbancheater(_src,"Night Vision Detected", "This Player tried to use Night Vision",true,true)
elseif (_type == "antiresourcestop") then
kickorbancheater(_src,"Resource Stopped", "This Player tried to stop/start a Resource",true,true)
elseif (_type == "pedchanged") then
kickorbancheater(_src,"Ped Changed", "This Player tried to change his PED",true,true)
elseif (_type == "freecam") then
kickorbancheater(_src,"FreeCam Detected", "This Player tried to use Freecam (Fallout or similar)",true,true)
elseif (_type == "infiniteammo") then
kickorbancheater(_src,"Infinite Ammo Detected", "This Player tried to put Infinite Ammo",true,true)
elseif (_type == "resourcestarted") then
kickorbancheater(_src,"AntiResourceStart", "This Player tried to start a resource",true,true)
elseif (_type == "menyoo") then
kickorbancheater(_src,"Anti Menyoo", "This Player tried to inject Menyoo Menu",true,true)
elseif (_type == "givearmour") then
kickorbancheater(_src,"Anti Give Armor", "This Player tried to Give Armor",true,true)
elseif (_type == "aimassist") then
kickorbancheater(_src,"Aim Assist", "This Player tried Aim Assist Detected. Mode: ",false,false)
elseif (_type == "infinitestamina") then
kickorbancheater(_src,"Anti Infinite Stamina", "This Player tried to use Infinite Stamina",true,true)
elseif (_type == "superjump") then
if IsPlayerUsingSuperJump(_src) then
kickorbancheater(_src,"Superjump Detected", "This Player tried to use Superjump",true,true)
end
elseif (_type == "vehicleweapons") then
kickorbancheater(_src,"Vehicle Weapons Detected", "This Player tried to use Vehicle Weapons",true,true)
elseif (_type == "blacklistedtask") then
kickorbancheater(_src,"Blacklisted Task", "Tried to execute a blacklisted task.",true,true)
elseif (_type == "blacklistedanim") then
kickorbancheater(_src,"Blacklisted Anim", "Tried executing a blacklisted anim. This player might not be a cheater.",true,true)
elseif (_type == "receivedpickup") then
kickorbancheater(_src,"Pickup received", "Pickup received.",true,true)
elseif (_type == "shotplayerwithoutbeingonhisscreen") then
kickorbancheater(_src,"Anti Aimbot/TriggerBot", "Hit a Player Without Being in his Screen. Possible Aimbot/TriggerBot/RageBot. Distance Difference.",false,false) -- can do wrong ban
elseif (_type == "aimbot") then
kickorbancheater(_src,"Anti Aimbot", "Aimbot detected.",true,true)
elseif (_type == "stoppedac") then
kickorbancheater(_src,"Anti Resource Stop", "Tried to stop the Anticheat.",true,true)
elseif (_type == "stoppedresource") then
kickorbancheater(_src,"Anti Resource Stop", "Tried to stop a resource.",true,true)
end
end)
RegisterNetEvent('JzKD3yfGZMSLTqu9L4Qy')
AddEventHandler('JzKD3yfGZMSLTqu9L4Qy', function(resource, info)
local _src = source
if resource ~= nil and info ~= nil then
kickorbancheater(_src,"Injection detected", "Injection detected in resource: "..resource.. "Type: "..info,true,true)
end
end)
RegisterNetEvent('tYdirSYpJtB77dRC3cvX')
AddEventHandler('tYdirSYpJtB77dRC3cvX', function()
local _src = source
local players = {}
for _,v in pairs(GetPlayers()) do
table.insert(players, {
name = GetPlayerName(v),
id = v
})
end
kickorbancheater(_src,"Give Weapon To Ped", "This Player tried Give Weapon to Ped.",true,true)
end)
if Config.AntiResource then
RegisterNetEvent('PJHxig0KJQFvQsrIhd5h')
AddEventHandler('PJHxig0KJQFvQsrIhd5h', function(Metadata, Files)
local _src = source
local _mdata = Metadata
local _files = Files
if _mdata ~= nil then
for k,v in pairs(_mdata) do
if not Config.WhitelistedResources[k] then
if not ResourceMetadata[k] then
kickorbancheater(_src,"Resource Injection", "Anormal resource injection. Resource: "..k,true,true)
end
if json.encode(ResourceMetadata[k]) ~= json.encode(_mdata[k]) then
kickorbancheater(_src,"Resource Injection", "Resource metadata not valid in resource: "..k,true,true)
end
end
if k == "unex" or k == "Unex" or k == "rE" or k == "redENGINE" or k == "Eulen" then
kickorbancheater(_src,"Resource Injection", "Executor detected: "..k,true,true)
end
end
for k,v in pairs(ResourceMetadata) do
if not Config.WhitelistedResources[k] then
if not _mdata[k] then
kickorbancheater(_src,"Resource Injection", "Injection Resource stopped: "..k,true,true)
end
if json.encode(_mdata[k]) ~= json.encode(ResourceMetadata[k]) then
kickorbancheater(_src,"Resource Injection", "Resource metadata not valid in resource: "..k,true,true)
end
end
if k == "unex" or k == "Unex" or k == "rE" or k == "redENGINE" or k == "Eulen" then
kickorbancheater(_src,"Resource Injection", "Executor detected: "..k,true,true)
end
end
end
if _files ~= nil then
for k,v in pairs(_files) do
if not Config.WhitelistedResources[k] then
if json.encode(ResourceFiles[k]) ~= json.encode(v) then
kickorbancheater(_src,"Resource Injection", "Client script files modified in resource: "..k,true,true)
end
end
end
end
end)
end
------------------------------------
-------- Explosion Event --------
------------------------------------
AddEventHandler('explosionEvent', function(sender, ev)
local name = GetPlayerName(sender)
local _src = source
-- We need to make sure it is original from explosion sender.
if ev.damageScale ~= 0.0 and ev.ownerNetId == 0 then
kickorbancheater(_src,"ExplosionEvent Detected", "Explosion Type: "..ev.explosionType,true,true)
CancelEvent()
end
end)
-----
--Maybe need rework from entity created to entitycreating for performance of server side. -- need rework
-- Disable it for a while since it need to be reworked.
-----
if Config.AntiEntity then
AddEventHandler('entityCreating', function(entity)
local src = NetworkGetEntityOwner(entity)
local type = GetEntityType(entity)
if type == 1 then
kickorbancheater(src,"Ped Spawn Detected", "This Player tried to spawn ped",true,true)
CancelEvent()
elseif type == 2 then
kickorbancheater(src,"Vehicle Spawn Detected", "This Player tried to vehicle spawn",true,true)
CancelEvent()
elseif type == 3 then
kickorbancheater(src,"Object Spawn Detected", "This Player tried to object spawn",true,true)
CancelEvent()
end
end)
end
------------------------------------
-------- Fake Message Chat --------
------------------------------------
RegisterNetEvent('chat:server:ServerPSA')
AddEventHandler('chat:server:ServerPSA', function()
local _src = source
kickorbancheater(_src,"Fake message detected", "Fake message detected",true,true)
end)
------------------------------------
-------- Anti Weapon Flag --------
------------------------------------
RegisterServerEvent('rwe:WeaponFlag')
AddEventHandler('rwe:WeaponFlag', function(weapon)
local _src = source
TriggerClientEvent("rwe:RemoveInventoryWeapons", _src)
kickorbancheater(_src,"Anti Weapon Flag", "Gave self a gun. Weapon: "..weapon,true,true)
end)
------------------------------------
-------- Entities Created --------
------------------------------------
AddEventHandler('entityCreated', function(entity) --- this can ban wrong
if not DoesEntityExist(entity) then
return
end
local src = NetworkGetEntityOwner(entity)
local entID = NetworkGetNetworkIdFromEntity(entity)
local model = GetEntityModel(entity)
local hash = GetHashKey(entity)
if Config.AntiSpawnVehicles then
for i, objName in ipairs(Config.BlacklistedVehicles) do
if model == objName then
TriggerClientEvent("rwe:DeleteCars", -1,entID)
Citizen.Wait(800)
kickorbancheater(src,"Blacklist Vehicle Spawned", "Object: "..objName.. " Model: "..model.. " Entity: "..entity.. " Hash: "..hash,false,false)
end
end
end
if Config.AntiSpawnPeds then
for i, objName in ipairs(Config.BlacklistedPeds) do
if model == objName then
TriggerClientEvent("rwe:DeletePeds", -1, entID)
Citizen.Wait(800)
kickorbancheater(src,"Blacklist Ped Spawned", "Object: "..objName.. " Model: "..model.. " Entity: "..entity.. " Hash: "..hash,false,false)
end
break
end
end
if Config.AntiSpawnObjects then
for i, objName in ipairs(Config.BlacklistedObjects) do
if model == objName then
TriggerClientEvent("rwe:DeleteEntity", -1, entID)
Citizen.Wait(800)
kickorbancheater(src,"Blacklist Object Spawned", "Object: "..objName.. " Model: "..model.. " Entity: "..entity.. " Hash: "..hash,false,false)
break
end
end
end
end)
------------------------------------
-------- Blacklisted Events --------
------------------------------------
if Config.EventsDetect then
for k, v in pairs(Config.Events) do
RegisterServerEvent(v)
AddEventHandler(v, function()
local _src = source
kickorbancheater(_src,"Blacklisted Events", "Blacklisted Event Caught. Event: "..v,true,true)
CancelEvent()
end)
end
end
if Config.ProtectPoliceEvent then
for k, v in pairs(Config.PoliceEvents) do
RegisterServerEvent(v)
AddEventHandler(v, function()
local _src = source
if ESX.GetPlayerFromId(_src).getJob().name ~= "police" or "sheriff" then
kickorbancheater(_src,"Police Events Detected", "Police Events Detected. Event: "..v,true,true)
end
end)
end
end
if Config.ProtectAmbulanceEvent then
for k, v in pairs(Config.AmbulanceEvents) do
RegisterServerEvent(v)
AddEventHandler(v, function()
local _src = source
if ESX.GetPlayerFromId(_src).getJob().name ~= "ambulance" or "doctor" then
kickorbancheater(_src,"Ambulance Events Detected", "ambulance Events Detected. Event: "..v,true,true)
end
end)
end
end
------------------------------------
-------- Blacklisted Word ----------
------------------------------------
AddEventHandler('chatMessage', function(source, color, message)
local _src = source
if not message then
return
end
if Config.AntiBlacklistedWords then
for k, v in pairs(Config.BlacklistWords) do
if string.match(message, v) then
Citizen.Wait(1500)
kickorbancheater(_src,"Blacklist Words Detected", "Blacklist Words Detected. Words: "..v,true,true)
CancelEvent()
end
return
end
end
end)
RegisterServerEvent('_chat:messageEntered')
AddEventHandler('_chat:messageEntered', function(author, color, message)
if not message then
return
end
local src = source
for k, v in pairs(Config.BlacklistWords) do
if string.match(message, v) then
Citizen.Wait(1500)
kickorbancheater(src,"Blacklist Words Detected", "Blacklist Words Detected. Words: "..v,true,true)
CancelEvent()
end
return
end
end)
------------------------------------
-------- Blacklisted Command -------
------------------------------------
Citizen.CreateThread(function()
for i=1, #Config.BlacklistedCommands, 1 do
RegisterCommand(Config.BlacklistedCommands[i], function(source)
local _src = source
kickorbancheater(_src,"Blacklist Command Detected", "Blacklist Command Detected.",true,true)
end)
end
end)
------------------------------------
-------- Admin Command -------
------------------------------------
RegisterCommand("entitywipe", function(source, args, raw)
local playerID = args[1]
if (playerID ~= nil and tonumber(playerID) ~= nil) then
EntityWipe(source, tonumber(playerID))
end
end, false)
function EntityWipe(source, target)
local _src = source
TriggerClientEvent("rwe:deletentity", -1, tonumber(target))
end
RegisterNetEvent('rwdeletevehiclesc', function(playerId)
local coords = GetEntityCoords(GetPlayerPed(playerId))
for _, v in pairs(GetAllVehicles()) do
local objCoords = GetEntityCoords(v)
local dist = #(coords - objCoords)
if dist < 2000 then
if DoesEntityExist(v) then
DeleteEntity(v)
end
end
end
end)
RegisterNetEvent('rwdeletepedsc', function(playerId)
local coords = GetEntityCoords(GetPlayerPed(playerId))
for _, v in pairs(GetAllPeds()) do
local objCoords = GetEntityCoords(v)
local dist = #(coords - objCoords)
if dist < 2000 then
if DoesEntityExist(v) then
DeleteEntity(v)
end
end
end
end)
RegisterNetEvent('rwdeleteobjectsc', function(playerId)
local coords = GetEntityCoords(GetPlayerPed(playerId))
for _, v in pairs(GetAllObjects()) do
local objCoords = GetEntityCoords(v)
local dist = #(coords - objCoords)
if dist < 2000 then
if DoesEntityExist(v) then
DeleteEntity(v)
end
end
end
end)
RegisterCommand("allentitywipe", function(source)
local _src = source
if IsPlayerWhitelisted(_src) then
TriggerEvent('rwdeletevehiclesc', tonumber(_src))
TriggerEvent('rwdeletepedsc', tonumber(_src))
TriggerEvent('rwdeleteobjectsc', tonumber(_src))
end
end, false)
----- EntityCreated different version with display
AddEventHandler('entityCreated', function(entity)
if DoesEntityExist(entity) then
local src = source
local model = GetEntityModel(entity)
if model == 3 then
for _, blacklistedProps in pairs(Config.BlacklistedObjects) do
if model == blacklistedProps then
TriggerClientEvent('rwe:antiProp', -1)
kickorbancheater(src,"Blacklist Object Detected", "Prop: "..blacklistedProps.. " https://mwojtasik.dev/tools/gtav/objects/search?name="..blacklistedProps,true,true)
CancelEvent()
return
end
end
elseif model == 2 then
for _, blacklistedVeh in pairs(Config.BlacklistedVehicles) do
if model == blacklistedVeh then
TriggerClientEvent('rwe:AntiVehicle', -1)
kickorbancheater(src,"Blacklist Vehicle Detected", "Vehicle: "..blacklistedVeh.. " https://www.gtabase.com/search?searchword="..blacklistedVeh,true,true)
CancelEvent()
return
end
end
elseif model == 1 then
for _, blacklistedPed in pairs(Config.BlacklistedPeds) do
if model == blacklistedPed then
TriggerClientEvent('rwe:antiPed', -1)
kickorbancheater(src,"Blacklist Ped Detected", "Ped: "..blacklistedPed.. " https://docs.fivem.net/peds/"..blacklistedPed..'.png',true,true)
CancelEvent()
return
end
end
end
end
end)
--------------------------------------------
-------- Anti Taze & Weapon Event & AntiCrash ----------
--------------------------------------------
AddEventHandler("weaponDamageEvent", function(sender, data)
if Config.AntiTaze then
local _src = sender
if data.weaponType == 911657153 or data.weaponType == GetHashKey("WEAPON_STUNGUN") then
kickorbancheater(_src,"Anti Taze Player.", "Tried to shoot with a taser",true,true)
CancelEvent()
end
end
end)
AddEventHandler("giveWeaponEvent", function(sender,data)
if Config.AntiGiveWeaponEvent then
local _src = sender
if data.givenAsPickup == false then
kickorbancheater(_src,"Anti Give Weapon(event)", "Tried to give weapons to a Ped",true,true)
CancelEvent()
end
end
end)
if Config.AntiCrash then
AddEventHandler("playerDropped", function(reason)
for k, v in pairs(Config.BlacklistedCrash) do
local _src = source
if reason ~= v then
else
kickorbancheater(_src,"Crash Detected", "Blacklist Crash Detected",true,true)
end
end
end)
end
local Charset = {}
for i = 65, 90 do
table.insert(Charset, string.char(i))
end
for i = 97, 122 do
table.insert(Charset, string.char(i))
end
RandomLetter = function(length)
if length > 0 then
return RandomLetter(length - 1) .. Charset[math.random(1, #Charset)]
end
return ""
end