-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathserver.lua
115 lines (100 loc) · 3.08 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
local function OnPlayerConnecting(name, _, deferrals)
local player = source
local isIdtypeAlreadyInUse = false
local isIdtypeAlreadyInUse2 = false
local idtype
if Config.VerifyBoth then
local idtype2
end
local identifiers = GetPlayerIdentifiers(player)
deferrals.defer()
Wait(0)
deferrals.update(string.format('Checking Connection...', name))
if Config.VerifyBoth then
for _, v in pairs(identifiers) do
if string.find(v, 'steam') then
idtype = v
break
end
end
for _, v in pairs(identifiers) do
if string.find(v, 'license') then
idtype2 = v
break
end
end
else
for _, v in pairs(identifiers) do
if string.find(v, Config.VerificationMethod) then
idtype = v
break
end
end
end
Wait(2500)
deferrals.update(string.format('Checking if you are not already on the server...', name))
if Config.VerifyBoth then
isIdtypeAlreadyInUse = IsIdtypeInUse(idtype, 'steam')
isIdtypeAlreadyInUse2 = IsIdtypeInUse(idtype2, 'license')
else
isIdtypeAlreadyInUse = IsIdtypeInUse(idtype, Config.VerificationMethod)
end
Wait(2500)
if Config.VerifyBoth then
if isIdtypeAlreadyInUse or isIdtypeAlreadyInUse2 then
deferrals.done('It looks like you are already on the server....')
if Config.EnableDiscordLogs then
local dcsend = {
{
['title']= Config.DiscordTitle,
['color'] = Config.DiscordColor,
['description'] = 'Player Identifiers: **'..idtype..' / '..idtype2..'**',
['footer']= {
['text']= 'bulgar_dconnect_block',
},
}
}
PerformHttpRequest(Config.DiscordWebhookLink, function(err, text, headers) end, 'POST', json.encode({ username = Config.DiscordUserName, embeds = dcsend}), { ['Content-Type'] = 'application/json' })
end
else
deferrals.done()
-- Add any additional defferals here you may need for example queue system!
end
else
if isIdtypeAlreadyInUse then
deferrals.done('It looks like you are already on the server....')
if Config.EnableDiscordLogs then
local dcsend = {
{
['title']= Config.DiscordTitle,
['color'] = Config.DiscordColor,
['description'] = 'Player Identifier: **'..idtype..'**',
['footer']= {
['text']= 'bulgar_dconnect_block',
},
}
}
PerformHttpRequest(Config.DiscordWebhookLink, function(err, text, headers) end, 'POST', json.encode({ username = Config.DiscordUserName, embeds = dcsend}), { ['Content-Type'] = 'application/json' })
end
else
deferrals.done()
-- Add any additional defferals here you may need for example queue system!
end
end
end
AddEventHandler('playerConnecting', OnPlayerConnecting)
function IsIdtypeInUse(idtype, vmethod)
local players = GetPlayers()
for _, player in pairs(players) do
local identifiers = GetPlayerIdentifiers(player)
for _, id in pairs(identifiers) do
if string.find(id, vmethod) then
local playerIdtype = id
if playerIdtype == idtype then
return true
end
end
end
end
return false
end