-
Notifications
You must be signed in to change notification settings - Fork 10
/
server.lua
377 lines (343 loc) · 14.6 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
local ESX = nil
local BanList = {}
local ThisPlayer = {}
local charset = 'abcdefghijklmnopqrstuvwxyz0123456789'
local charTable = {}
for c in charset:gmatch"." do
table.insert(charTable, c)
end
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
AddEventHandler("onMySQLReady",function()
loadBanList()
end)
function loadBanList()
MySQL.Async.fetchAll('SELECT * FROM vcac_ban',{},function (data)
BanList = {}
for i=1, #data, 1 do
table.insert(BanList, {
identifier = data[i].identifier,
license = data[i].license,
liveid = data[i].liveid,
xblid = data[i].xblid,
discord = data[i].discord,
playerip = data[i].playerip,
reason = data[i].reason,
report_id = data[i].report_id,
})
end
end)
end
RegisterCommand('DBanReload', function(source)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.permission_level >= 4 then
if xPlayer.get('aduty') then
loadBanList()
else
TriggerClientEvent('chatMessage', source, "[SYSTEM]", {255, 0, 0}, " ^0Shoma nemitavanid dar halat ^1OffDuty ^0az command haye admini estefade konid!")
end
else
TriggerClientEvent('chatMessage', source, "[SYSTEM]", {255, 0, 0}, " ^0Shoma Ejaze in kar ro nadarid!")
end
end)
function string.random(length)
local randomString = ""
for i = 1, length do
randomString = randomString .. charTable[math.random(1, #charTable)]
end
return randomString
end
if VCAC_A.TriggerDetection then
for i=1 , #VCAC_B.Events do
RegisterServerEvent(VCAC_B.Events[i])
AddEventHandler(VCAC_B.Events[i], function()
local src = source
sendToDiscord(DiscordVCAC,src,"[EXECUTER]","**Executer Name: **"..GetPlayerName(src).."\n\n**Event Name: **"..VCAC_B.Events[i],3447003)
TriggerEvent('VCAC:Ban1FuckinCheater', src,"Tried to use detected events!")
return CancelEvent()
end)
end
end
Citizen.CreateThread(function()
while true and VCAC_A.ConnectionCheck do
updateCheck()
Citizen.Wait(10000)
TriggerClientEvent("VCAC:TargetCheck", -1)
end
end)
Citizen.CreateThread(function()
while true and VCAC_A.ConnectionCheck do
Citizen.Wait(45000)
RemToCheck()
end
end)
PlayerCheck = {}
PlayerWarning = {}
function AddToCheck(source)
if ESX then
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer then
if not PlayerCheck[xPlayer.identifier] then
PlayerCheck[xPlayer.identifier] = {Name = xPlayer.name}
end
end
end
end
function WarnPlayer(xPlayer)
if PlayerWarning[xPlayer.identifier] then
if PlayerWarning[xPlayer.identifier].Warn >= 3 then
PlayerWarning[xPlayer.identifier] = nil
sendToDiscord(VCAC_A.DiscordVCACWarn,xPlayer.source,"[Not Connect to anticheat]","**Name: **"..GetPlayerName(xPlayer.source),12370112)
DropPlayer(xPlayer.source, "[VCAC]: You are not connected to ANTI-CHEAT.")
else
PlayerWarning[xPlayer.identifier].Warn = PlayerWarning[xPlayer.identifier].Warn + 1
print("Player Disconnected! | "..xPlayer.name.." | "..PlayerWarning[xPlayer.identifier].Warn.."/4")
end
else
PlayerWarning[xPlayer.identifier] = {Warn = 0}
end
end
function RemToCheck()
if ESX then
for _,v in pairs(GetPlayers()) do
local xPlayer = ESX.GetPlayerFromId(v)
if xPlayer then
if PlayerCheck[xPlayer.identifier] then
PlayerCheck[xPlayer.identifier] = nil
PlayerWarning[xPlayer.identifier] = nil
else
print("Not Player To List!")
end
end
end
end
end
function updateCheck()
if ESX then
for _,v in pairs(GetPlayers()) do
local xPlayer = ESX.GetPlayerFromId(v)
if xPlayer then
if not PlayerCheck[xPlayer.identifier] then
WarnPlayer(xPlayer)
end
end
end
end
end
AddEventHandler('playerDropped', function()
local _source = source
if _source ~= nil then
local identifier = GetPlayerIdentifier(_source)
PlayerCheck[identifier] = nil
PlayerWarning[identifier] = nil
end
end)
AddEventHandler('explosionEvent', function(sender, ev)
if VCAC_A.DetectExplosions then
CancelEvent()
if VCACExplosion.ExplosionsList[ev.explosionType] then
if VCACExplosion.ExplosionsList[ev.explosionType].ban then
sendToDiscord(VCAC_A.DiscordVCACexplosion,sender,"[CREATE BLOCKED EXPLOSION]","**Creator Name: **"..GetPlayerName(sender).."\n\n**Explosion Name: **"..VCACExplosion.ExplosionsList[ev.explosionType].name,1752220)
TriggerEvent('VCAC:Ban1FuckinCheater', sender,"Tried to create block list Explosions")
else
sendToDiscord(VCAC_A.DiscordVCACexplosion,sender,"[CREATE BLOCKED EXPLOSION]","**Creator Name: **"..GetPlayerName(sender).."\n\n**Explosion Name: **"..VCACExplosion.ExplosionsList[ev.explosionType].name,1752220)
end
else
sendToDiscord(VCAC_A.DiscordVCACexplosion,sender,"[CREATE UNKNOWN EXPLOSION]","**Creator Name: **"..GetPlayerName(sender).."\n\n**Explosion TYPE: **"..ev.explosionType,1752220)
end
end
end)
RegisterServerEvent('VCAC:BanMySelf')
AddEventHandler('VCAC:BanMySelf', function(reason,checkadmin)
local xPlayer = ESX.GetPlayerFromId(source)
if checkadmin then
if xPlayer.permission_level >= 10 then return false end
end
if not xPlayer.get('aduty') then
TriggerEvent('VCAC:Ban1FuckinCheater', source,reason)
end
end)
RegisterServerEvent('VCAC:CheckBack')
AddEventHandler('VCAC:CheckBack', function()
AddToCheck(source)
end)
AddEventHandler('entityCreated', function(entity)
local entity = entity
if not DoesEntityExist(entity) then
return
end
local src = NetworkGetEntityOwner(entity)
local entID = NetworkGetNetworkIdFromEntity(entity)
local model = GetEntityModel(entity)
local hash = GetHashKey(entity)
local SpawnerName = GetPlayerName(src)
-- Check Blocked Vehicles
if VCAC_A.AntiSpawnVehicles then
for i, objName in ipairs(VCAC_E.AntiNukeBlacklistedVehicles) do
if model == GetHashKey(objName.name) then
TriggerClientEvent("VCAC:DeleteCars", -1,entID)
Citizen.Wait(800)
if objName.log then
sendToDiscord(VCAC_A.DiscordVCACObject,src,"[SPAWN BLOCKED VEHICLE]","**-Spawner Name: **"..SpawnerName.."\n\n**-Object Name: **"..objName.name.."\n\n**-Spawn Model:** "..model.."\n\n**-Entity ID:** "..entity.."\n\n**-Hash ID:** "..hash,15105570)
end
if objName.ban then
TriggerEvent('VCAC:Ban1FuckinCheater', src,"Tried to spawn block list vehicles")
end
break
end
end
end
-- Check Blocked Peds
if VCAC_A.AntiSpawnPeds then
for i, objName in ipairs(VCAC_E.AntiNukeBlacklistedPeds) do
if model == GetHashKey(objName.name) then
TriggerClientEvent("VCAC:DeletePeds", -1, entID)
Citizen.Wait(800)
if objName.log then
sendToDiscord(VCAC_A.DiscordVCACObject,src,"[SPAWN BLOCKED PEDS]","**-Spawner Name: **"..SpawnerName.."\n\n**-Object Name: **"..objName.name.."\n\n**-Spawn Model:** "..model.."\n\n**-Entity ID:** "..entity.."\n\n**-Hash ID:** "..hash,15105570)
end
if objName.ban then
TriggerEvent('VCAC:Ban1FuckinCheater', src,"Tried to spawn block list peds")
end
break
end
end
end
-- Check Blocked Nuke
if VCAC_A.AntiNuke then
for i, objName in ipairs(VCAC_E.AntiNukeBlacklistedObjects) do
if model == GetHashKey(objName) then
TriggerClientEvent("VCAC:DeleteEntity", -1, entID)
Citizen.Wait(800)
if objName.log then
sendToDiscord(VCAC_A.DiscordVCACObject,src,"[SPAWN BLOCKED OBJECT]","**-Spawner Name: **"..SpawnerName.."\n\n**-Object Name: **"..objName.name.."\n\n**-Spawn Model:** "..model.."\n\n**-Entity ID:** "..entity.."\n\n**-Hash ID:** "..hash,15105570)
end
if objName.ban then
TriggerEvent('VCAC:Ban1FuckinCheater', src,"Tried to spawn block list objects")
end
break
end
end
end
end)
AddEventHandler("chatMessage",function(source, n, message)
for i=1 , #VCAC_BWords.Words do
if string.match(message:lower(),VCAC_BWords.Words[i]:lower()) then
TriggerEvent('VCAC:Ban1FuckinCheater', source,"Send block word to chat")
return CancelEvent()
end
end
end)
AddEventHandler('VCAC:Ban1FuckinCheater', function(source,reason)
local identifier
local license
local liveid = "no info"
local xblid = "no info"
local discord = "no info"
local playerip
local sourceplayername = GetPlayerName(source)
for k,v in ipairs(GetPlayerIdentifiers(source))do
if string.sub(v, 1, string.len("steam:")) == "steam:" then
identifier = v
elseif string.sub(v, 1, string.len("license:")) == "license:" then
license = v
elseif string.sub(v, 1, string.len("live:")) == "live:" then
liveid = v
elseif string.sub(v, 1, string.len("xbl:")) == "xbl:" then
xblid = v
elseif string.sub(v, 1, string.len("discord:")) == "discord:" then
discord = v
elseif string.sub(v, 1, string.len("ip:")) == "ip:" then
playerip = v
end
end
ban(source,identifier,license,liveid,xblid,discord,playerip,sourceplayername,reason)
end)
function ban(source,identifier,license,liveid,xblid,discord,playerip,sourceplayername,reason)
if not ThisPlayer[identifier] then
local report_id = string.random(7).."-"..string.random(7).."-"..string.random(7).."-"..string.random(7)
ThisPlayer[identifier] = true
table.insert(BanList, {
identifier = identifier,
license = license,
liveid = liveid,
xblid = xblid,
discord = discord,
playerip = playerip,
reason = reason,
report_id = report_id,
})
MySQL.Async.execute('INSERT INTO vcac_ban (identifier,license,liveid,xblid,discord,playerip,sourceplayername,reason,report_id) VALUES (@identifier,@license,@liveid,@xblid,@discord,@playerip,@sourceplayername,@reason,@report_id)',{
['@identifier'] = identifier,
['@license'] = license,
['@liveid'] = liveid,
['@xblid'] = xblid,
['@discord'] = discord,
['@playerip'] = playerip,
['@sourceplayername'] = sourceplayername,
['@reason'] = reason,
['@report_id'] = report_id,
},nil)
TriggerClientEvent('chatMessage', -1, "[VCAC Detected]", {255, 0, 0}, sourceplayername.." permanent Ban from server." )
DropPlayer(source, 'You have been automatically banned from VCAC. This ban never will expire. Please do note that the ViceCity staff is unlikely to assist you with this ban.\nYour ban ID is '..report_id)
sendToDiscord(VCAC_A.DiscordVCACBan,source,"[CHEATER BAN]","**Name :**"..sourceplayername.."\n\n**"..identifier.."**\n\n**"..license.."**\n\n<@!"..string.gsub(discord, "discord:", "")..">\n\n**"..playerip.."**\n\n**Reason :**"..reason.."\n\n**Report ID :**"..report_id.."\n\n Enjoy ban xD",15158332)
end
end
function sendToDiscord(DiscordLog,source,title,des,color)
if VCAC_A.DiscordLog then
local nick = GetPlayerName(source) or "None"
local embed = {
{
["color"] = color,
["title"] = title,
["description"] = des,
["footer"] = {
["text"] = "ViceCity AntiCheat | Dev: SoHeil#4935",
},}}
Wait(100)
PerformHttpRequest(DiscordLog, function(err, text, headers) end, 'POST', json.encode({username = nick, embeds = embed}), { ['Content-Type'] = 'application/json' })
end
end
AddEventHandler('playerConnecting', function (playerName,setKickReason)
local steamID = "empty"
local license = "empty"
local liveid = "empty"
local xblid = "empty"
local discord = "empty"
local playerip = "empty"
for k,v in ipairs(GetPlayerIdentifiers(source))do
if string.sub(v, 1, string.len("steam:")) == "steam:" then
steamID = v
elseif string.sub(v, 1, string.len("license:")) == "license:" then
license = v
elseif string.sub(v, 1, string.len("live:")) == "live:" then
liveid = v
elseif string.sub(v, 1, string.len("xbl:")) == "xbl:" then
xblid = v
elseif string.sub(v, 1, string.len("discord:")) == "discord:" then
discord = v
elseif string.sub(v, 1, string.len("ip:")) == "ip:" then
playerip = v
end
end
if (Banlist == {}) then
Citizen.Wait(1000)
end
for i = 1, #BanList, 1 do
if
((tostring(BanList[i].identifier)) == tostring(steamID)
or (tostring(BanList[i].license)) == tostring(license)
or (tostring(BanList[i].liveid)) == tostring(liveid)
or (tostring(BanList[i].xblid)) == tostring(xblid)
or (tostring(BanList[i].discord)) == tostring(discord)
or (tostring(BanList[i].playerip)) == tostring(playerip))
then
setKickReason(VCAC_A.BanMassage..'\nYour ban ID is '..BanList[i].report_id)
CancelEvent()
end
end
end)