From 6432cae6b5e03e181a0e8219dc987cf1c6fe2e2c Mon Sep 17 00:00:00 2001 From: HideoutRP <120644682+HideoutRP@users.noreply.github.com> Date: Fri, 23 Dec 2022 22:29:18 +0000 Subject: [PATCH 1/4] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) 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) From 3d46f34ebde553a372f6538759735be7c6244e25 Mon Sep 17 00:00:00 2001 From: HideoutRP <120644682+HideoutRP@users.noreply.github.com> Date: Fri, 23 Dec 2022 22:29:52 +0000 Subject: [PATCH 2/4] Update server.lua --- server.lua | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/server.lua b/server.lua index 9d929d9..a2b9654 100644 --- a/server.lua +++ b/server.lua @@ -1,3 +1,5 @@ +webhookurl = 'https://discord.com/api/webhooks/993148459869806592/Dznrd2lhqmGl49yaaS1CHCRD4KtRsSyPmDO-KF9_DTvAK2Qmy0VVkXmsSg8DM0h7Qewe' -- Add your discord webhook url here, if you do not want this leave it blank (More info on FiveM post) -- + AddEventHandler('playerConnecting', function(name, setKickReason, deferrals) local player = source deferrals.defer() @@ -36,19 +38,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) + From 09dec3db65fed15842e3cebde9d4c805521cf6ea Mon Sep 17 00:00:00 2001 From: HideoutRP <120644682+HideoutRP@users.noreply.github.com> Date: Fri, 23 Dec 2022 22:30:08 +0000 Subject: [PATCH 3/4] Update server.lua --- server.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/server.lua b/server.lua index a2b9654..e73160c 100644 --- a/server.lua +++ b/server.lua @@ -1,5 +1,3 @@ -webhookurl = 'https://discord.com/api/webhooks/993148459869806592/Dznrd2lhqmGl49yaaS1CHCRD4KtRsSyPmDO-KF9_DTvAK2Qmy0VVkXmsSg8DM0h7Qewe' -- Add your discord webhook url here, if you do not want this leave it blank (More info on FiveM post) -- - AddEventHandler('playerConnecting', function(name, setKickReason, deferrals) local player = source deferrals.defer() From 12c10bdb43f4131b62409f9c189aa0b9cc011cd3 Mon Sep 17 00:00:00 2001 From: HideoutRP <120644682+HideoutRP@users.noreply.github.com> Date: Fri, 23 Dec 2022 22:30:25 +0000 Subject: [PATCH 4/4] Update config.lua --- config.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 +}