Skip to content

Commit 91d926f

Browse files
[admin & admin2] addendum to #296 (#297)
* use table.concat instead * use the correct permission general.tab_adminchat * Add command handler for admin chat * Add setting to change the command name * Add new line at end of file * Check if the message is not empty
1 parent 44053e2 commit 91d926f

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

[admin]/admin/server/admin_server.lua

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,12 +1580,8 @@ end )
15801580

15811581
addCommandHandler(get("adminChatCommandName"),
15821582
function(thePlayer, cmd, ...)
1583-
if hasObjectPermissionTo (thePlayer, "general.adminpanel", false) then
1584-
local msg = ""
1585-
for i, word in ipairs(arg) do
1586-
msg = msg .. (i > 1 and " " or "") .. word
1587-
end
1588-
triggerEvent("aAdminChat", thePlayer, msg)
1583+
if hasObjectPermissionTo (thePlayer, "general.tab_adminchat", false) and #arg > 0 then
1584+
triggerEvent("aAdminChat", thePlayer, table.concat(arg, " "))
15891585
end
15901586
end
15911587
)

[admin]/admin2/meta.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,5 +274,10 @@
274274
accept="[true],[false]"
275275
desc="Parse console commands."
276276
/>
277+
<setting name="#adminChatCommandName" value="a"
278+
group="General"
279+
friendlyname="Admin chat command name"
280+
desc="The command name for admin chat."
281+
/>
277282
</settings>
278283
</meta>

[admin]/admin2/server/admin_server.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,11 @@ addEventHandler(
401401
end
402402
end
403403
)
404+
405+
addCommandHandler(get("adminChatCommandName"),
406+
function(thePlayer, cmd, ...)
407+
if (hasObjectPermissionTo(thePlayer, "general.tab_adminchat", false) and #arg > 0) then
408+
triggerEvent("aAdminChat", thePlayer, table.concat(arg, " "))
409+
end
410+
end
411+
)

0 commit comments

Comments
 (0)