├── License.md ├── README.md ├── __resource.lua ├── client.lua └── server.lua /License.md: -------------------------------------------------------------------------------- 1 | ## Terms of Use 2 | 3 | (Below the term "product" is used to describe the script / modification) 4 | 5 | This script is freeware and is not to be exploited for personal, financial or commercial gain. This product is provided without any form of warranty. 6 | Therefore, responsibility for any damages caused by this product or its misuse rest solely with the user, as the author(s) will accept no liability. 7 | 8 | - This copy of terms must remain in its original state and must not be modified in anyway 9 | 10 | - These terms must be alongside the product at all times 11 | 12 | - Do not re-release with out permission (just ask for permission) 13 | 14 | - Do not redistribute to any other sites. This script is only to be published on verified sites by FAXES 15 | 16 | - Editing / abusing these terms will result in action 17 | 18 | ### Summery 19 | So basically you can edit anything with the product (except the terms), but you can not release the product nor release the edited version without written permission from FAXES. 20 | 21 | Terms are also available at 22 | [www.faxes.zone/scripts/terms](http://faxes.zone/scripts/terms) 23 | 24 | 25 | ![alt text](http://faxes.zone/files/logos/FAXES%20ToUSML.png "FAXES ToU Icon") 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **Server Password By FAXES** 2 | 3 | **About** 4 | This resource gives you (the server owner) the ability to add a password to your FiveM server. This can be used for development servers, white-listed servers and for anything else! This gives the user that option to make their life. 5 | 6 | **In the Download** 7 | >__resource.lua 8 | client.lua 9 | server.lua 10 | 11 | 12 | **Pictures** 13 | 14 | http://faxes.zone/imagebanks/y240mr.png 15 | http://faxes.zone/imagebanks/285rex.png 16 | 17 |
18 | 19 | **Features** 20 | - Server-side password for extra security 21 | - Kicks when invalid password is entered 22 | - String must be matched (case wise) 23 | - Future plans to make a countdown so if the password is not entered in *x* seconds the player is kicked 24 | - Temp-ban system when a player is kicked for invalid password attempts (configurable time) 25 | - Time remaining shown in "ban" message when player tries to reconnect 26 | - Multiple password entry attempts 27 | - Bypass ACE permission system 28 | 29 | **Changelogs** 30 | [1.1](https://forum.fivem.net/t/release-server-password-make-your-server-secure-and-scum-free-1-0/180499/34) 31 | 32 | **Requirements** 33 | None. This is a standalone script. 34 | 35 | **Downloads:** 36 | * [Download via Github](https://github.com/FAXES/ServerPassword) 37 | * Or via Direct Download 38 | **If you use this script it is highly suggested to put "Locked Server" into your server name** 39 | 40 | 41 | **Installation** 42 | Place in your resources folder, just like any other resource. 43 | 44 | 45 | If you have any issues or comments please put them below. :christmas_tree: 46 | 47 | **Original Topic** 48 | https://forum.fivem.net/t/release-server-password-make-your-server-secure-and-scum-free-1-1/180499 49 | -------------------------------------------------------------------------------- /__resource.lua: -------------------------------------------------------------------------------- 1 | ------------------------------ 2 | -- Server Password, Made by -- 3 | -- FAXES & GlitchDetector -- 4 | ------------------------------ 5 | -- Config can be found in the files! 6 | 7 | client_script "client.lua" 8 | server_script "server.lua" -------------------------------------------------------------------------------- /client.lua: -------------------------------------------------------------------------------- 1 | ------------------------------ 2 | -- Server Password, Made by -- 3 | -- FAXES & GlitchDetector -- 4 | ------------------------------ 5 | 6 | --- CONFIG --- 7 | local attempts = 3 -- Amount of attempts a user can have 8 | 9 | --------------------------------------------------------------------------------------------------------------- 10 | local passwordPassed = false 11 | 12 | function KeyboardInput(textEntry, inputText, maxLength) -- Thanks to Flatracer for the function. 13 | AddTextEntry('FMMC_KEY_TIP1', textEntry) 14 | DisplayOnscreenKeyboard(1, "FMMC_KEY_TIP1", "", inputText, "", "", "", maxLength) 15 | while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do 16 | Citizen.Wait(0) 17 | end 18 | if UpdateOnscreenKeyboard() ~= 2 then 19 | local result = GetOnscreenKeyboardResult() 20 | Citizen.Wait(500) 21 | return result 22 | else 23 | Citizen.Wait(500) 24 | return nil 25 | end 26 | end 27 | 28 | function drawText(text, x, y) 29 | local resx, resy = GetScreenResolution() 30 | SetTextFont(0) 31 | SetTextScale(0.8, 0.8) 32 | SetTextProportional(true) 33 | SetTextColour(41, 170, 226, 255) 34 | SetTextCentre(true) 35 | SetTextDropshadow(0, 0, 0, 0, 0) 36 | SetTextEntry("STRING") 37 | AddTextComponentString(text) 38 | DrawText((float(x) / 1.5) / resx, ((float(y) - 6) / 1.5) / resy) 39 | end 40 | 41 | function float(num) 42 | num = num + 0.00001 43 | return num 44 | end 45 | 46 | --------------------------------------------------------------------------------------------------------------- 47 | AddEventHandler('onClientMapStart', function() 48 | Wait(1000) 49 | local ped = GetPlayerPed(-1) 50 | FreezeEntityPosition(ped, true) 51 | TriggerServerEvent("Fax:ServerPassword:Initialize") 52 | end) 53 | 54 | RegisterNetEvent("Fax:ServerPassword:ShowPasswordPrompt") 55 | AddEventHandler("Fax:ServerPassword:ShowPasswordPrompt", function() 56 | local password = KeyboardInput("Enter server password (" .. attempts .. " attempt" .. (attempts == 1 and "" or "s") .. " remaining)", "", 30) 57 | attempts = attempts - 1 58 | TriggerServerEvent("Fax:ServerPassword:CheckPassword", password, attempts) 59 | end) 60 | 61 | RegisterNetEvent('Fax:ServerPassword:PassedPassword') 62 | AddEventHandler('Fax:ServerPassword:PassedPassword', function() 63 | local ped = GetPlayerPed(-1) 64 | FreezeEntityPosition(ped, false) 65 | TriggerEvent('chatMessage', "^2Passed Password!") 66 | end) 67 | -- A FaxDetector Project ;) -------------------------------------------------------------------------------- /server.lua: -------------------------------------------------------------------------------- 1 | ------------------------------ 2 | -- Server Password, Made by -- 3 | -- FAXES & GlitchDetector -- 4 | ------------------------------ 5 | 6 | --- CONFIG --- 7 | password = "fax" -- Set server password here 8 | kickMessage = "Invalid Password" -- The invalid password kick message. Default: Invalid Password 9 | timeRanOutMsg = "You ran out of time to enter the password" --Not active yet! Dont worry about this 10 | timeoutMessage = "Invalid password. Please wait %s before trying to connect again." -- Displayed if the user tries to attempt too many times, this locks them out of the server for x seconds 11 | invalidPasswordTimeout = 5 * 60 -- Wait time before the player can re-join. Change the first value Not the '* 60'. Default: 5 minutes 12 | 13 | --------------------------------------------------------------------------------------------------------------- 14 | local Timeouts = {} 15 | 16 | function Timeout(source) 17 | Timeouts[GetPlayerIdentifier(source, 1)] = os.time() + invalidPasswordTimeout 18 | end 19 | 20 | function SecondsToClock(seconds) 21 | local seconds = tonumber(seconds) 22 | 23 | if seconds <= 0 then 24 | return "00", "00", "00", "00:00:00" 25 | else 26 | hours = string.format("%02.f", math.floor(seconds/3600)); 27 | mins = string.format("%02.f", math.floor(seconds/60 - (hours*60))); 28 | secs = string.format("%02.f", math.floor(seconds - hours*3600 - mins *60)); 29 | return hours, mins, secs, hours .. ":" .. mins .. ":" .. secs 30 | end 31 | end 32 | 33 | function TimesToSexy(m,s) 34 | local r = "" 35 | if m ~= "00" then 36 | r = r .. m .. "m" 37 | end 38 | if r ~= "" then r = r .. " " end 39 | r = r .. s .. "s" 40 | return r 41 | end 42 | 43 | function GetSexyTime(seconds) 44 | local _,m,s = SecondsToClock(seconds) 45 | return TimesToSexy(m,s) 46 | end 47 | 48 | --------------------------------------------------------------------------------------------------------------- 49 | AddEventHandler("playerConnecting", function(name, setMessage, deferrals) 50 | local source = source 51 | local timeout = Timeouts[GetPlayerIdentifier(source, 1)] 52 | if timeout then 53 | if timeout > os.time() then 54 | local sexytime = GetSexyTime(timeout - os.time()) 55 | deferrals.defer() 56 | deferrals.update((timeoutMessage):format(sexytime)) 57 | Wait(500) 58 | deferrals.done((timeoutMessage):format(sexytime)) 59 | end 60 | end 61 | end) 62 | 63 | RegisterServerEvent("Fax:ServerPassword:Initialize") 64 | AddEventHandler("Fax:ServerPassword:Initialize", function() 65 | local source = source 66 | if not IsPlayerAceAllowed(source, "Bypass") then 67 | TriggerClientEvent("Fax:ServerPassword:ShowPasswordPrompt", source) 68 | else 69 | TriggerClientEvent("Fax:ServerPassword:PassedPassword", source, true) 70 | end 71 | end) 72 | 73 | RegisterServerEvent('Fax:ServerPassword:CheckPassword') 74 | AddEventHandler('Fax:ServerPassword:CheckPassword', function(Newpassword, attempts) 75 | local clPassword = Newpassword 76 | local s = source 77 | 78 | if clPassword == password then 79 | TriggerClientEvent("Fax:ServerPassword:PassedPassword", s) 80 | elseif password ~= clPassword then 81 | if attempts <= 0 then 82 | Timeout(s) 83 | DropPlayer(s, kickMessage) 84 | else 85 | TriggerClientEvent("Fax:ServerPassword:ShowPasswordPrompt", s) 86 | end 87 | else 88 | Timeout(s) 89 | DropPlayer(s, kickMessage) 90 | end 91 | end) 92 | -- A FaxDetector Project ;) --------------------------------------------------------------------------------