Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom ban deferral cards with images/customisation supported #821

Merged
merged 11 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions language/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"kicked": "Gekickt von %s, \nGrund: %s",
"banned": "Du wurdest von diesem server gebannt, \nGrund: %s, \nBann Läuft am %s ab.",
"reasonadd": " ( Spielername: %s ), \nGebannt von: %s",
"bansuffix": ", \nGebannt von: ",
"nongiven": "Keinen gegeben",
"announcement": "Announcement",
"announcementguide": "Send an announcement to all players",
Expand Down
1 change: 1 addition & 0 deletions language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"kicked": "Kicked by %s, Reason: %s",
"banned": "You have been banned from this Server, Reason: %s, Ban Expires: %s",
"reasonadd": " ( Nickname: %s ), Banned by: %s",
"bansuffix": ", Banned by: ",
Blumlaut marked this conversation as resolved.
Show resolved Hide resolved
"nongiven": "None Provided",
"announcement": "Announcement",
"announcementguide": "Send an announcement to all players",
Expand Down
1 change: 1 addition & 0 deletions language/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"kicked": "Has sido kickeado por %s, Razon: %s",
"banned": "Has sido baneado del servidor, Razon: %s, Expira: %s",
"reasonadd": " ( El jugador: %s ), ha sido baneado por: %s",
"bansuffix": ", ha sido baneado por: ",
"nongiven": "No se ha proporcionado",
"announcement": "Anuncio",
"announcementguide": "Send an announcement to all players",
Expand Down
1 change: 1 addition & 0 deletions language/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"kicked": "Éjecté par %s, Raison : %s",
"banned": "Vous avez été banni du serveur, \nRaison : %s, Expiration du bannissement : %s",
"reasonadd": " ( Pseudo : %s ), banni par : %s",
"bansuffix": ", banni par : ",
"nongiven": "Non autorisé",
"announcement": "Announcement",
"announcementguide": "Send an announcement to all players",
Expand Down
1 change: 1 addition & 0 deletions language/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"kicked": "Espulso da %s, Motivo: %s",
"banned": "Sei stato bandito da questo server, Motivo: %s, Il Ban Scade: %s",
"reasonadd": " ( Nickname: %s ), Bandito da: %s",
"bansuffix": ", Bandito da: ",
"nongiven": "Non fornito",
"announcement": "Announcement",
"announcementguide": "Send an announcement to all players",
Expand Down
1 change: 1 addition & 0 deletions language/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"kicked": "Gekickt door %s, Reden: %s",
"banned": "Je bent verbannen van deze Server, Reden: %s, Ban Vervalt: %s",
"reasonadd": " ( Gebruikersnaam: %s ), Verbannen door: %s",
"bansuffix": ", Verbannen door: ",
"nongiven": "Geen reden opgegeven",
"announcement": "Mededeling",
"announcementguide": "Stuur een mededeling naar alle spelers",
Expand Down
1 change: 1 addition & 0 deletions language/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"kicked": "Wyrzucony przez %s, Powód: %s",
"banned": "Zostałeś zbanowany na tym serwerze, Powód: %s, Czas trwania: %s",
"reasonadd": " ( Gracz: %s ), Zablokowany przez: %s",
"bansuffix": ", Zablokowany przez: ",
"nongiven": "Nie podano",
"announcement": "Ogłoszenie",
"announcementguide": "Wyślij ogłoszenie do wszystkich graczy",
Expand Down
25 changes: 24 additions & 1 deletion server/admin_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,31 @@ Citizen.CreateThread(function()
updateBan(blacklisted.banid,newBanData) -- send it off!
end
PrintDebugMessage("Connection of "..getName(player).." Declined, Banned for "..blacklist[bi].reason..", Ban ID: "..blacklist[bi].banid.."\n", 3)
deferrals.done(string.format( GetLocalisedText("bannedjoin"), blacklist[bi].reason, formatDateString(blacklist[bi].expire), blacklist[bi].banid))

local banMessageTitleColour = GetConvar("ea_banMessageTitleColour", "#354557")
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.")
local banMessageWatermark = GetConvar("ea_banMessageWatermark", "https://i.imgur.com/vRFuxUN.png")
Gravxd marked this conversation as resolved.
Show resolved Hide resolved

if banMessageShowStaff == "false" then
banMessageStaffName = 'Server Staff'
end

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(
'<div style="background-color: rgba(30, 30, 30, 0.5); padding: 20px; border: solid 2px var(--color-modal-border); border-radius: var(--border-radius-normal); margin-top: 25px; position: relative;"><h1 style="color:' .. banMessageTitleColour .. ';">' .. banMessageServerName .. '</h1><br><h2>'.. banMessageSubHeader ..'</h2><br><p style="font-size: 1.25rem; padding: 0px"><strong>Expires:</strong> ' ..
formatDateString(blacklist[bi].expire) .. '<br><strong>Banned By:</strong> ' .. banMessageStaffName ..
' <br> <strong>Ban Reason:</strong> ' .. banMessageReason ..
' <br> <strong>Ban ID:</strong> <code style="letter-spacing: 2px; background-color: #ff7f5059; padding: 2px 4px; border-radius: 6px;">' ..
blacklist[bi].banid ..
'</code><br><br>' .. banMessageFooter .. ' <span style="font-style: italic;"></span></p><img src="' .. banMessageWatermark .. '" style="position: absolute;right: 15px;bottom: 15px;opacity: 65%;"></div>')
return

end
end
end
Expand Down
9 changes: 9 additions & 0 deletions shared/util_shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,15 @@ function mergeTables(t1, t2)
return t
end

-- used to get raw ban reason
function getRawBanReason(inputStr, suffix)
Blumlaut marked this conversation as resolved.
Show resolved Hide resolved
local endPos = string.find(inputStr, suffix)
if endPos then
return string.sub(inputStr, 1, endPos-1)
else
return inputStr
end
end

-- terrible function to look for URLs in a string
function matchURL(text_with_URLs)
Expand Down
Loading