Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Forked Version INCLUDES
- Option to enable discord webhook & random password generator
![image](https://i.imgur.com/tdcdPTT.png)


# Server Locked with Password
![image](https://user-images.githubusercontent.com/71755882/209230620-285de4fd-9175-465f-91c5-87d76557feff.png)

Expand Down
6 changes: 4 additions & 2 deletions config.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
config = {
password = "mypassword", -- Max of 30 characters
message = "Enter server password to continue", -- Message will show above password field
failMessage = "Incorrect password" -- Failed message will show after wrong password is entered
}
failMessage = "Incorrect password", -- Failed message will show after wrong password is entered
DiscordAndPassword = false, -- Enables/Disables discord webhook with random generated password
DiscordWebhook = "INSERT_DISCORD_WEBHOOK" -- Discord web hook goes here
}
62 changes: 60 additions & 2 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,77 @@ AddEventHandler('playerConnecting', function(name, setKickReason, deferrals)
}
}
}
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 == config.password then

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))
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)