2013-02-01 14:55:42 -05:00
|
|
|
function HandleHelpCommand(Split, Player)
|
2012-01-26 17:44:37 -05:00
|
|
|
local PluginManager = cRoot:Get():GetPluginManager()
|
|
|
|
|
2013-02-01 14:55:42 -05:00
|
|
|
local LinesPerPage = 9;
|
|
|
|
local CurrentPage = 1;
|
|
|
|
local CurrentLine = 0;
|
|
|
|
local PageRequested = 1;
|
|
|
|
local Output = {};
|
2012-01-26 17:44:37 -05:00
|
|
|
|
2013-02-01 14:55:42 -05:00
|
|
|
if (#Split == 2) then
|
|
|
|
PageRequested = tonumber(Split[2]);
|
2012-01-26 17:44:37 -05:00
|
|
|
end
|
|
|
|
|
2013-02-01 14:55:42 -05:00
|
|
|
local Process = function(Command, Permission, HelpString)
|
|
|
|
if not(Player:HasPermission(Permission)) then
|
|
|
|
return false;
|
|
|
|
end;
|
|
|
|
if (HelpString == "") then
|
|
|
|
return false;
|
|
|
|
end;
|
2012-01-26 17:44:37 -05:00
|
|
|
|
2013-02-01 14:55:42 -05:00
|
|
|
CurrentLine = CurrentLine + 1;
|
|
|
|
CurrentPage = math.floor(CurrentLine / LinesPerPage) + 1;
|
|
|
|
if (CurrentPage ~= PageRequested) then
|
|
|
|
return false;
|
|
|
|
end;
|
|
|
|
table.insert(Output, cChatColor.Blue .. Command .. HelpString);
|
2012-01-26 17:44:37 -05:00
|
|
|
end
|
2013-02-01 14:55:42 -05:00
|
|
|
|
|
|
|
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 .. "- All commands - " .. cChatColor.Gold .. "[Page " .. PageRequested .. " / " .. CurrentPage .. "]");
|
|
|
|
for idx, msg in ipairs(Output) do
|
|
|
|
Player:SendMessage(msg);
|
|
|
|
end;
|
2012-01-26 17:44:37 -05:00
|
|
|
|
|
|
|
return true
|
|
|
|
end
|