From a634821f25bb35febb83c1caca9eb1f23e10b741 Mon Sep 17 00:00:00 2001 From: Linventif Date: Tue, 27 Feb 2024 23:55:44 +0100 Subject: [PATCH] add: server filter maintenance --- lua/gmod_integration/client/cl_gui_admin.lua | 12 ++++++++ lua/gmod_integration/server/sv_filtrers.lua | 31 ++++++++++---------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/lua/gmod_integration/client/cl_gui_admin.lua b/lua/gmod_integration/client/cl_gui_admin.lua index f0b0f59..e29d825 100644 --- a/lua/gmod_integration/client/cl_gui_admin.lua +++ b/lua/gmod_integration/client/cl_gui_admin.lua @@ -63,6 +63,18 @@ local possibleConfig = { -- end, -- ["category"] = "Main" -- }, + ["maintenance"] = { + ["label"] = "Maintenance", + ["description"] = "Activate or deactivate maintenance mode.", + ["type"] = "checkbox", + ["value"] = function(setting, value) + return value + end, + ["onEdit"] = function(setting, value) + saveConfig(setting, value == "Enabled" && true || false) + end, + ["category"] = "Main" + }, ["filterOnBan"] = { ["label"] = "Block Discord Ban Player", ["description"] = "Block players banned on the discord server.", diff --git a/lua/gmod_integration/server/sv_filtrers.lua b/lua/gmod_integration/server/sv_filtrers.lua index c5a2565..28bcccb 100644 --- a/lua/gmod_integration/server/sv_filtrers.lua +++ b/lua/gmod_integration/server/sv_filtrers.lua @@ -4,25 +4,19 @@ local function filterMessage(reason) local Message = { - "", - "This server has player filtering enabled", - "You are not allowed to join this server", + "\n----------------------------------------\n", + "You cannot join this server", "", "Reason: " .. reason, - "", - "For more information, please contact the server owner", "Help URL: " .. (gmInte.config.supportLink && gmInte.config.supportLink || "No Support Link"), "", - "You can also contact us on our discord server", - "https://gmod-integration.com/discord", - "", "Have a nice day", - "", + "\n----------------------------------------\n", "Service provided by Gmod Integration", } for k, v in pairs(Message) do - Message[k] = v .. "\n" + Message[k] = "\n" .. v end return table.concat(Message) @@ -58,18 +52,25 @@ local function playerFilter(data) gmInte.http.get("/players/" .. data.steamID64, function(code, body) - if (!body || !body.trust) then return end + if (!gmInte.config.maintenance && !body.bypassMaintenance) then + game.KickID(data.networkid, filterMessage("The server is currently under maintenance and you are not whitelisted.")) + end if (!checkBanStatus(body.ban)) then - game.KickID(data.networkid, filterMessage("You are banned from this server")) + game.KickID(data.networkid, filterMessage("You are banned from this server.")) end if (!checkDiscordBanStatus(body.discord_ban)) then - game.KickID(data.networkid, filterMessage("You are banned from our discord server")) + game.KickID(data.networkid, filterMessage("You are banned from our discord server.")) end - if (!checkTrustFactor(body.trust)) then - game.KickID(data.networkid, filterMessage("Your trust factor is too low")) + -- if (!checkTrustFactor(body.trust)) then + -- game.KickID(data.networkid, filterMessage("Your trust factor is too low.")) + -- end + end, + function (err) + if (!gmInte.config.maintenance) then + game.KickID(data.networkid, filterMessage("The server is currently under maintenance and we cannot verify your account.\nVerification URL: https://verif.gmod-integration.com")) end end )