diff --git a/README.md b/README.md index acc7799..80e87e0 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/config.lua b/config.lua index 2724355..16ecf6e 100644 --- a/config.lua +++ b/config.lua @@ -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 -} \ No newline at end of file + 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 +} diff --git a/server.lua b/server.lua index 9d929d9..e73160c 100644 --- a/server.lua +++ b/server.lua @@ -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) +