2014-08-04 12:12:15 +00:00
|
|
|
// vim: set ts=4 sw=4 tw=99 noet:
|
|
|
|
//
|
|
|
|
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
|
|
|
// Copyright (C) The AMX Mod X Development Team.
|
|
|
|
//
|
|
|
|
// This software is licensed under the GNU General Public License, version 3 or higher.
|
|
|
|
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
|
|
|
// https://alliedmods.net/amxmodx-license
|
|
|
|
|
|
|
|
//
|
|
|
|
// Admin Help Plugin
|
|
|
|
//
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2004-03-05 19:35:38 +00:00
|
|
|
#include <amxmodx>
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2014-07-27 12:59:09 +00:00
|
|
|
new g_cvarDisplayClientMessage;
|
|
|
|
new g_cvarHelpAmount;
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public plugin_init()
|
|
|
|
{
|
|
|
|
register_plugin("Admin Help", AMXX_VERSION_STR, "AMXX Dev Team")
|
|
|
|
register_dictionary("adminhelp.txt")
|
|
|
|
register_concmd("amx_help", "cmdHelp", 0, "<page> [nr of cmds (only for server)] - displays this help")
|
2014-07-27 12:59:09 +00:00
|
|
|
|
|
|
|
g_cvarDisplayClientMessage = register_cvar("amx_help_display_msg", "1")
|
|
|
|
g_cvarHelpAmount = register_cvar("amx_help_amount_per_page", "10")
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public client_putinserver(id)
|
|
|
|
{
|
2014-07-27 12:59:09 +00:00
|
|
|
if (get_pcvar_num(g_cvarDisplayClientMessage) && !is_user_bot(id))
|
|
|
|
{
|
|
|
|
set_task(15.0, "dispInfo", id)
|
|
|
|
}
|
2004-08-13 11:20:12 +00:00
|
|
|
}
|
2005-02-21 00:31:52 +00:00
|
|
|
|
2015-07-16 22:26:30 +00:00
|
|
|
public client_disconnected(id)
|
2005-09-12 21:06:24 +00:00
|
|
|
{
|
2005-02-21 00:31:52 +00:00
|
|
|
remove_task(id)
|
|
|
|
}
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public cmdHelp(id, level, cid)
|
|
|
|
{
|
2004-05-16 11:31:41 +00:00
|
|
|
new arg1[8], flags = get_user_flags(id)
|
2013-08-05 15:44:15 +00:00
|
|
|
new start = read_argv(1, arg1, charsmax(arg1)) ? str_to_num(arg1) : 1
|
2014-07-27 12:59:09 +00:00
|
|
|
new lHelpAmount = get_pcvar_num(g_cvarHelpAmount)
|
|
|
|
|
2007-03-30 01:52:10 +00:00
|
|
|
// HACK: ADMIN_ADMIN is never set as a user's actual flags, so those types of commands never show
|
|
|
|
if (flags > 0 && !(flags & ADMIN_USER))
|
|
|
|
{
|
|
|
|
flags |= ADMIN_ADMIN;
|
|
|
|
}
|
2014-07-27 12:59:09 +00:00
|
|
|
|
2004-05-16 11:31:41 +00:00
|
|
|
if (id == 0 && read_argc() == 3)
|
2014-07-27 12:59:09 +00:00
|
|
|
{
|
|
|
|
if (read_argv(2, arg1, charsmax(arg1)))
|
|
|
|
{
|
|
|
|
lHelpAmount = str_to_num(arg1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lHelpAmount <= 0)
|
|
|
|
{
|
|
|
|
lHelpAmount = 10
|
|
|
|
}
|
2004-05-16 11:31:41 +00:00
|
|
|
|
|
|
|
if (--start < 0)
|
2014-07-27 12:59:09 +00:00
|
|
|
{
|
2004-05-16 11:31:41 +00:00
|
|
|
start = 0
|
2014-07-27 12:59:09 +00:00
|
|
|
}
|
2004-05-16 11:31:41 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
new clcmdsnum = get_concmdsnum(flags, id)
|
2004-05-16 11:31:41 +00:00
|
|
|
|
|
|
|
if (start >= clcmdsnum)
|
2014-07-27 12:59:09 +00:00
|
|
|
{
|
2004-05-16 11:31:41 +00:00
|
|
|
start = clcmdsnum - 1
|
2014-07-27 12:59:09 +00:00
|
|
|
}
|
2004-05-16 11:31:41 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
console_print(id, "^n----- %L -----", id, "HELP_COMS")
|
|
|
|
|
2004-05-16 11:31:41 +00:00
|
|
|
new info[128], cmd[32], eflags
|
2014-07-27 12:59:09 +00:00
|
|
|
new end = start + lHelpAmount
|
2004-05-16 11:31:41 +00:00
|
|
|
|
|
|
|
if (end > clcmdsnum)
|
2014-07-27 12:59:09 +00:00
|
|
|
{
|
2004-05-16 11:31:41 +00:00
|
|
|
end = clcmdsnum
|
2014-07-27 12:59:09 +00:00
|
|
|
}
|
2004-05-16 11:31:41 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
for (new i = start; i < end; i++)
|
|
|
|
{
|
2013-08-05 15:44:15 +00:00
|
|
|
get_concmd(i, cmd, charsmax(cmd), eflags, info, charsmax(info), flags, id)
|
2005-09-12 21:06:24 +00:00
|
|
|
console_print(id, "%3d: %s %s", i + 1, cmd, info)
|
2004-05-16 11:31:41 +00:00
|
|
|
}
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
console_print(id, "----- %L -----", id, "HELP_ENTRIES", start + 1, end, clcmdsnum)
|
2004-05-16 11:31:41 +00:00
|
|
|
|
|
|
|
if (end < clcmdsnum)
|
2014-07-27 12:59:09 +00:00
|
|
|
{
|
2005-09-12 21:06:24 +00:00
|
|
|
console_print(id, "----- %L -----", id, "HELP_USE_MORE", end + 1)
|
2014-07-27 12:59:09 +00:00
|
|
|
}
|
2004-05-16 11:31:41 +00:00
|
|
|
else
|
2014-07-27 12:59:09 +00:00
|
|
|
{
|
2005-09-12 21:06:24 +00:00
|
|
|
console_print(id, "----- %L -----", id, "HELP_USE_BEGIN")
|
2014-07-27 12:59:09 +00:00
|
|
|
}
|
2004-05-16 11:31:41 +00:00
|
|
|
|
|
|
|
return PLUGIN_HANDLED
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public dispInfo(id)
|
|
|
|
{
|
|
|
|
client_print(id, print_chat, "%L", id, "TYPE_HELP")
|
2013-08-05 15:44:15 +00:00
|
|
|
|
|
|
|
static amx_nextmap, mp_timelimit = 0
|
|
|
|
if( !mp_timelimit )
|
|
|
|
{
|
|
|
|
amx_nextmap = get_cvar_pointer("amx_nextmap")
|
|
|
|
mp_timelimit = get_cvar_pointer("mp_timelimit")
|
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
new nextmap[32]
|
2013-08-05 15:44:15 +00:00
|
|
|
if( amx_nextmap )
|
|
|
|
{
|
|
|
|
get_pcvar_string(amx_nextmap, nextmap, charsmax(nextmap))
|
|
|
|
}
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2013-08-05 15:44:15 +00:00
|
|
|
if (get_pcvar_float(mp_timelimit))
|
2005-09-12 21:06:24 +00:00
|
|
|
{
|
|
|
|
new timeleft = get_timeleft()
|
|
|
|
|
|
|
|
if (timeleft > 0)
|
|
|
|
{
|
|
|
|
client_print(id, print_chat, "%L", id, "TIME_INFO_1", timeleft / 60, timeleft % 60, nextmap)
|
2014-07-27 12:59:09 +00:00
|
|
|
}
|
|
|
|
else if (amx_nextmap)
|
|
|
|
{
|
2005-09-12 21:06:24 +00:00
|
|
|
client_print(id, print_chat, "%L", id, "TIME_INFO_2", nextmap)
|
|
|
|
}
|
|
|
|
}
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|