2016-02-13 11:19:37 +00:00
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
2016-02-16 13:10:00 +00:00
-- Copyright (C) 2015-2016 Timo 'Timothy' Smit
2016-02-13 11:19:37 +00:00
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- at your option any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
2016-08-29 20:00:11 +00:00
local auth = require " luascripts.wolfadmin.auth.auth "
2016-02-18 18:42:17 +00:00
local commands = require " luascripts.wolfadmin.commands.commands "
2016-08-29 20:18:20 +00:00
local settings = require " luascripts.wolfadmin.util.settings "
2016-02-13 11:19:37 +00:00
function commandHelp ( clientId , cmdArguments )
2016-02-18 18:42:17 +00:00
local cmds = commands.getadmin ( )
2016-02-13 11:19:37 +00:00
if # cmdArguments == 0 then
local availableCommands = { }
for command , data in pairs ( cmds ) do
2016-08-29 20:00:11 +00:00
if data [ " function " ] and data [ " flag " ] and auth.isallowed ( clientId , data [ " flag " ] ) == 1 and ( not data [ " hidden " ] or ( type ( data [ " hidden " ] ) == " function " and not data [ " hidden " ] ( ) ) ) then
2016-02-13 11:19:37 +00:00
table.insert ( availableCommands , command )
end
end
2016-09-01 14:13:35 +00:00
et.trap_SendConsoleCommand ( et.EXEC_APPEND , " cchat " .. clientId .. " \" ^dhelp: ^9 " .. # availableCommands .. " " .. ( ( settings.get ( " g_standalone " ) == 1 ) and " available " or " additional " ) .. " commands (open console for the full list) \" ; " )
2016-02-13 11:19:37 +00:00
local cmdsOnLine , cmdsBuffer = 0 , " "
for _ , command in pairs ( availableCommands ) do
cmdsBuffer = cmdsBuffer ~= " " and cmdsBuffer .. string.format ( " %-12s " , command ) or string.format ( " %-12s " , command )
cmdsOnLine = cmdsOnLine + 1
if cmdsOnLine == 6 then
et.trap_SendConsoleCommand ( et.EXEC_APPEND , " csay " .. clientId .. " \" ^f " .. cmdsBuffer .. " \" ; " )
cmdsBuffer = " "
cmdsOnLine = 0
end
end
if cmdsBuffer ~= " " then
et.trap_SendConsoleCommand ( et.EXEC_APPEND , " csay " .. clientId .. " \" ^f " .. cmdsBuffer .. " \" ; " )
end
et.trap_SendConsoleCommand ( et.EXEC_APPEND , " csay " .. clientId .. " \" ^9Type ^2!help ^d[command] ^9for help with a specific command. \" ; " )
return false
elseif # cmdArguments > 0 then
local helpCmd = string.lower ( cmdArguments [ 1 ] )
if cmds [ helpCmd ] ~= nil and ( not cmds [ helpCmd ] [ " hidden " ] or ( type ( cmds [ helpCmd ] [ " hidden " ] ) == " function " and not cmds [ helpCmd ] [ " hidden " ] ( ) ) ) then
et.trap_SendConsoleCommand ( et.EXEC_APPEND , " csay " .. clientId .. " \" ^dhelp: ^9help for '^2 " .. helpCmd .. " ^9': \" ; " )
et.trap_SendConsoleCommand ( et.EXEC_APPEND , " csay " .. clientId .. " \" ^dfunction: ^9 " .. cmds [ helpCmd ] [ " help " ] .. " \" ; " )
et.trap_SendConsoleCommand ( et.EXEC_APPEND , " csay " .. clientId .. " \" ^dsyntax: ^9 " .. cmds [ helpCmd ] [ " syntax " ] .. " \" ; " )
et.trap_SendConsoleCommand ( et.EXEC_APPEND , " csay " .. clientId .. " \" ^dflag: ^9'^2 " .. cmds [ helpCmd ] [ " flag " ] .. " ^9' \" ; " )
return true
end
end
return false
end
2016-09-01 14:13:35 +00:00
commands.addadmin ( " help " , commandHelp , auth.PERM_HELP , " display commands available to you or help on a specific command " , " ^9(^hcommand^9) " , ( settings.get ( " g_standalone " ) == 0 ) )