From 983d87e44356c4cfc8f8908ec365006323a4dbe0 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 27 Jul 2013 16:24:03 +0100 Subject: Added correct core plugin --- MCServer/Plugins/Core/help.lua | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 MCServer/Plugins/Core/help.lua (limited to 'MCServer/Plugins/Core/help.lua') diff --git a/MCServer/Plugins/Core/help.lua b/MCServer/Plugins/Core/help.lua new file mode 100644 index 000000000..339fc054b --- /dev/null +++ b/MCServer/Plugins/Core/help.lua @@ -0,0 +1,41 @@ +function HandleHelpCommand(Split, Player) + local PluginManager = cRoot:Get():GetPluginManager() + + local LinesPerPage = 8; + local CurrentPage = 1; + local CurrentLine = 0; + local PageRequested = 1; + local Output = {}; + + if (#Split == 2) then + PageRequested = tonumber(Split[2]); + end + + local Process = function(Command, Permission, HelpString) + if not(Player:HasPermission(Permission)) then + return false; + end; + if (HelpString == "") then + return false; + end; + + CurrentLine = CurrentLine + 1; + CurrentPage = math.floor(CurrentLine / LinesPerPage) + 1; + if (CurrentPage ~= PageRequested) then + return false; + end; + table.insert(Output, cChatColor.Blue .. Command .. HelpString); + end + + PluginManager:ForEachCommand(Process); + + -- CurrentPage now contains the total number of pages, and Output has the individual help lines to be sent + + Player:SendMessage(cChatColor.Purple .. "---------- [COMMANDS HELP " .. cChatColor.Gold .. "(Page " .. PageRequested .. " / " .. CurrentPage .. ")" .. cChatColor.Purple .. "] -----------"); + Player:SendMessage(cChatColor.Purple .. "'-' means no prefix, '~' means a value is required."); + for idx, msg in ipairs(Output) do + Player:SendMessage(msg); + end; + + return true +end \ No newline at end of file -- cgit v1.2.3