forked from Its-Scru/scru_serverlock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.lua
More file actions
112 lines (103 loc) · 3.67 KB
/
server.lua
File metadata and controls
112 lines (103 loc) · 3.67 KB
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
AddEventHandler('playerConnecting', function(name, setKickReason, deferrals)
local player = source
deferrals.defer()
Wait(0)
local passcodeCard = {
["type"] = "AdaptiveCard",
["$schema"] = "http://adaptivecards.io/schemas/adaptive-card.json",
["version"] = "1.5",
["body"] = {
{
["type"] = "TextBlock",
["text"] = config.message,
["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"
}
}
}
}
}
if config.DiscordAndPassword then
local capital_letters = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
local low_letters = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
local numbers = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
math.randomseed(os.time())
local length = 10
local pass = ""
local choice = 0
for _ = 1, length do
choice = math.random(3)
-- Capital letters
if choice == 1 then
pass = pass .. capital_letters[math.random(#capital_letters)]
-- Low letters
elseif choice == 2 then
pass = pass .. low_letters[math.random(#low_letters)]
-- Numbers
else
pass = pass .. numbers[math.random(#numbers)]
end
end
local embedMsg = {}
timestamp = os.date("%c")
embedMsg = {
{
["color"] = FF0000,
["title"] = 'Password',
["description"] = 'Password: '..pass.. '\nPlayer Connecting: ' ..name.. "",
["footer"] ={
["text"] = timestamp.." (Server Time).",
},
}
}
PerformHttpRequest(config.DiscordWebhook,
function(err, text, headers)end, 'POST', json.encode({username = 'SCRU SERVERLOCK', avatar_url= '' ,embeds = embedMsg}), { ['Content-Type']= 'application/json' })
local show = true
while show do
Wait(0)
deferrals.presentCard(passcodeCard, function (data, rawdata)
if data.passcode == pass then
show = false
deferrals.done()
print(("%s entered the correct password!"):format(name))
else
deferrals.done(config.failMessage)
print(("%s tried to connect to the server with the wrong password!"):format(name))
end
end)
end
else
local show = true
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.failMessage)
print(("%s tried to connect to the server with the wrong password!"):format(name))
end
end)
end
end
end)