-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.lua
73 lines (70 loc) · 2.42 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
function GetPlayerIdentifierFromType(type, player)
local identifierCount = GetNumPlayerIdentifiers(player)
for count = 0, identifierCount do
local identifier = GetPlayerIdentifier(player, count)
if identifier and string.find(identifier, type) then
return identifier
end
end
return nil
end
AddEventHandler('playerConnecting', function(name, setKickReason, deferrals)
local player = source
local identifier = GetPlayerIdentifierFromType("license", player)
deferrals.defer()
Wait(0)
local passcodeCard = {
["type"] = "AdaptiveCard",
["$schema"] = "http://adaptivecards.io/schemas/adaptive-card.json",
["version"] = "1.5",
["body"] = {
{
["type"] = "TextBlock",
["text"] = config.passwordMessage,
["wrap"] = true,
["style"] = "heading"
},
{
["type"] = "Input.Text",
["placeholder"] = "Password",
["id"] = "passcode",
["isRequired"] = true,
["errorMessage"] = "Required Field*",
["maxLength"] = 30,
["style"] = "Password"
},
{
["type"] = "ActionSet",
["actions"] = {
{
["type"] = "Action.Submit",
["title"] = "Submit",
["style"] = "positive",
["id"] = "submit"
}
}
}
}
}
local show = true
for _, whitelistLicense in pairs(config.whitelistedUsers) do
if identifier == whitelistLicense then
deferrals.done()
print(("%s is whitelisted and entering the server."):format(name))
return
end
end
while show do
Wait(0)
deferrals.presentCard(passcodeCard, function (data, rawdata)
if data.passcode == config.password then
show = false
deferrals.done()
print(("%s entered the correct password!"):format(name))
else
deferrals.done(config.passwordFailMessage)
print(("%s tried to connect to the server with the wrong password!"):format(name))
end
end)
end
end)