Skip to content

Commit f939480

Browse files
Add admin chat command (#296)
Added command for quickly writing admin chat messages using /a [text] by default, and customizable in meta.xml to avoid conflicts per server
1 parent 32abd48 commit f939480

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ function aClientAdminChat ( message )
843843
local chat = guiGetText ( aTab5.AdminChat )
844844
guiSetText ( aTab5.AdminChat, (chat ~= "\n" and chat or "")..getPlayerName ( source )..": "..message )
845845
guiSetProperty ( aTab5.AdminChat, "CaratIndex", tostring ( string.len ( chat ) ) )
846-
if ( guiCheckBoxGetSelected ( aTab6.AdminChatOutput ) ) then outputChatBox ( "ADMIN> "..getPlayerName ( source )..": "..message, 255, 0, 0 ) end
846+
if ( guiCheckBoxGetSelected ( aTab6.AdminChatOutput ) ) then outputChatBox ( "ADMIN CHAT> "..getPlayerName ( source )..": "..message, 255, 0, 0 ) end
847847
if ( ( guiCheckBoxGetSelected ( aTab5.AdminChatSound ) ) and ( source ~= localPlayer ) ) then playSoundFrontEnd ( 13 ) end
848848
end
849849

[admin]/admin/meta.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,10 @@
372372
friendlyname="Player report categories"
373373
desc="List of report categories for reporting players."
374374
/>
375+
<setting name="*adminChatCommandName" value="a"
376+
friendlyname="Admin chat command name"
377+
desc="The command name for admin chat."
378+
/>
375379

376380
</settings>
377381

[admin]/admin/server/admin_server.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,18 @@ addEventHandler ( "aAdminChat", _root, function ( chat )
15681568
outputServerLog ("(ADMIN CHAT) "..tostring(getPlayerName(source))..": "..chat)
15691569
end )
15701570

1571+
addCommandHandler(get("adminChatCommandName"),
1572+
function(thePlayer, cmd, ...)
1573+
if hasObjectPermissionTo (thePlayer, "general.adminpanel", false) then
1574+
local msg = ""
1575+
for i, word in ipairs(arg) do
1576+
msg = msg .. (i > 1 and " " or "") .. word
1577+
end
1578+
triggerEvent("aAdminChat", thePlayer, msg)
1579+
end
1580+
end
1581+
)
1582+
15711583
addEventHandler('onElementDataChange', root,
15721584
function(dataName, oldValue )
15731585
if getElementType(source)=='player' and checkClient( false, source, 'onElementDataChange', dataName ) then

0 commit comments

Comments
 (0)