Skip to content

Commit 17d7014

Browse files
committed
Add limit to admin chat message length
Limit is 225 characters: the max chatbox message length, minus 7 for "ADMIN> ", minus 22 (max length for a player name), minus 2 (for ": ").
1 parent abbcb9c commit 17d7014

File tree

6 files changed

+14
-0
lines changed

6 files changed

+14
-0
lines changed

[admin]/admin/admin_definitions.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ function enum ( args, prefix )
1919
end
2020
end
2121

22+
-- MISC DEFINITIONS
23+
ADMIN_CHAT_MAXLENGTH = 225
24+
2225
-- EVENT CALLS
2326

2427
enum

[admin]/admin/client/gui/admin_main.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ y=y+B aTab1.VehicleHealth = guiCreateLabel ( 0.26, y, 0.25, 0.04, "Vehicle Heal
333333
guiGridListAddColumn ( aTab5.AdminPlayers, "Admins", 0.90 )
334334
aTab5.AdminChatSound = guiCreateCheckBox ( 0.79, 0.86, 0.18, 0.04, "Play Sound", true, true, aTab5.Tab )
335335
aTab5.AdminText = guiCreateEdit ( 0.03, 0.92, 0.80, 0.06, "", true, aTab5.Tab )
336+
guiEditSetMaxLength(aTab5.AdminText, ADMIN_CHAT_MAXLENGTH)
336337
aTab5.AdminSay = guiCreateButton ( 0.85, 0.92, 0.08, 0.06, "Say", true, aTab5.Tab )
337338
aTab5.AdminChatHelp = guiCreateButton ( 0.94, 0.92, 0.03, 0.06, "?", true, aTab5.Tab )
338339

[admin]/admin/server/admin_server.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,9 @@ end )
16311631

16321632
addEvent ( "aAdminChat", true )
16331633
addEventHandler ( "aAdminChat", root, function ( chat )
1634+
if #chat > ADMIN_CHAT_MAXLENGTH then
1635+
return
1636+
end
16341637
if checkClient( true, source, 'aAdminChat' ) then return end
16351638
for id, player in ipairs(getElementsByType("player")) do
16361639
if ( aPlayers[player]["chat"] ) then

[admin]/admin2/admin_definitions.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ function enum(args, prefix)
2121
end
2222
end
2323

24+
-- MISC DEFINITIONS
25+
ADMIN_CHAT_MAXLENGTH = 225
26+
2427
-- EVENT CALLS
2528

2629
enum(

[admin]/admin2/client/main/admin_chat.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function aChatTab.Create(tab)
2323
aChatTab.AdminChatSound = guiCreateCheckBox(0.81, 0.83, 0.18, 0.04, "Play Sound", aGetSetting("adminChatSound"), true, tab)
2424
aChatTab.AdminChatOutput = guiCreateCheckBox(0.81, 0.87, 0.18, 0.04, "Output", aGetSetting("adminChatOutput"), true, tab)
2525
aChatTab.AdminText = guiCreateEdit(0.01, 0.92, 0.78, 0.06, "", true, tab)
26+
guiEditSetMaxLength(aChatTab.AdminText, ADMIN_CHAT_MAXLENGTH)
2627
aChatTab.AdminSay = guiCreateButton(0.80, 0.92, 0.19, 0.06, "Say", true, tab)
2728

2829
addEventHandler("aClientAdminChat", root, aChatTab.onClientAdminChat)

[admin]/admin2/server/admin_server.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,9 @@ addEventHandler(
477477
"aAdminChat",
478478
root,
479479
function(chat)
480+
if #chat >= ADMIN_CHAT_MAXLENGTH then
481+
return
482+
end
480483
for id, player in ipairs(getElementsByType("player")) do
481484
if (aPlayers[player]["chat"]) then
482485
triggerClientEvent(player, "aClientAdminChat", source, chat)

0 commit comments

Comments
 (0)