From 791be4569fa0edd1d282909fb06cbf9fa992e18e Mon Sep 17 00:00:00 2001 From: Grav <75702884+Gravxd@users.noreply.github.com> Date: Tue, 30 Jan 2024 00:14:54 +0000 Subject: [PATCH] tweak(server/admin_server) extract ban reason dynamically (works with diff languages) --- server/admin_server.lua | 5 +++-- shared/util_shared.lua | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/server/admin_server.lua b/server/admin_server.lua index f1091a09..530810c3 100644 --- a/server/admin_server.lua +++ b/server/admin_server.lua @@ -948,7 +948,8 @@ Citizen.CreateThread(function() PrintDebugMessage("Connection of "..getName(player).." Declined, Banned for "..blacklist[bi].reason..", Ban ID: "..blacklist[bi].banid.."\n", 3) local banMessageTitleColour = GetConvar("ea_banMessageTitleColour", "#354557") - local banMessageServerName = GetConvar("ea_banMessageServerName", GetConvar("sv_projectName", "EasyAdmin")) local banMessageShowStaff = GetConvar("ea_banMessageShowStaff", "true") + local banMessageServerName = GetConvar("ea_banMessageServerName", GetConvar("sv_projectName", "EasyAdmin")) + local banMessageShowStaff = GetConvar("ea_banMessageShowStaff", "true") local banMessageStaffName = blacklist[bi].banner local banMessageFooter = GetConvar("ea_banMessageFooter", "You can appeal this by ban by visiting our discord.") local banMessageSubHeader = GetConvar("ea_banMessageSubHeader", "You have been banned from this server.") @@ -958,7 +959,7 @@ Citizen.CreateThread(function() banMessageStaffName = 'Server Staff' end - local banMessageReason = getStringUntilSuffix(blacklist[bi].reason, ", Banned by:") + local banMessageReason = getRawBanReason(blacklist[bi].reason, GetLocalisedText("bansuffix")) -- gives us a raw ban reason with their nickname as we don't want the staff member displayed due to our new convar // "banned by:" field deferrals.done( diff --git a/shared/util_shared.lua b/shared/util_shared.lua index 4f5bfb79..5c0d4980 100644 --- a/shared/util_shared.lua +++ b/shared/util_shared.lua @@ -330,7 +330,7 @@ function mergeTables(t1, t2) end -- used to get raw ban reason -function getStringUntilSuffix(inputStr, suffix) +function getRawBanReason(inputStr, suffix) local endPos = string.find(inputStr, suffix) if endPos then return string.sub(inputStr, 1, endPos-1)