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
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2004-02-21 20:30:04 +00:00
|
|
|
#if defined _amxmisc_included
|
|
|
|
#endinput
|
|
|
|
#endif
|
|
|
|
#define _amxmisc_included
|
|
|
|
|
2007-02-19 07:03:26 +00:00
|
|
|
#if !defined _amxmodx_included
|
2014-06-05 10:48:56 +00:00
|
|
|
#include <amxmodx>
|
2006-09-01 03:29:27 +00:00
|
|
|
#endif
|
|
|
|
|
2004-10-03 06:23:25 +00:00
|
|
|
stock is_user_admin(id)
|
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
new __flags = get_user_flags(id);
|
|
|
|
return (__flags > 0 && !(__flags & ADMIN_USER));
|
2004-10-03 06:23:25 +00:00
|
|
|
}
|
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
stock cmd_access(id, level, cid, num, bool:accesssilent = false)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
new has_access = 0;
|
2015-02-06 00:32:33 +00:00
|
|
|
if (id == (is_dedicated_server() ? 0 : 1))
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
has_access = 1;
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
else if (level == ADMIN_ADMIN)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (is_user_admin(id))
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
has_access = 1;
|
|
|
|
}
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
else if (get_user_flags(id) & level)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
has_access = 1;
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
else if (level == ADMIN_ALL)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
has_access = 1;
|
|
|
|
}
|
2004-07-24 11:02:49 +00:00
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
if (has_access == 0)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2007-08-03 15:26:22 +00:00
|
|
|
if (!accesssilent)
|
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
console_print(id, "%L", id, "NO_ACC_COM");
|
2007-08-03 15:26:22 +00:00
|
|
|
}
|
2007-03-05 19:30:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
if (read_argc() < num)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
new hcmd[32], hinfo[128], hflag;
|
2015-02-06 00:32:33 +00:00
|
|
|
get_concmd(cid, hcmd, charsmax(hcmd), hflag, hinfo, charsmax(hinfo), level);
|
|
|
|
console_print(id, "%L: %s %s", id, "USAGE", hcmd, hinfo);
|
2007-03-05 19:30:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
return 1;
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
stock access(id, level)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (level == ADMIN_ADMIN)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
return is_user_admin(id);
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
else if (level == ADMIN_ALL)
|
2007-03-30 02:04:30 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2004-07-31 01:00:20 +00:00
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
return (get_user_flags(id) & level);
|
2004-07-24 11:02:49 +00:00
|
|
|
}
|
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
/**
|
|
|
|
* Flags related to cmd_target:
|
|
|
|
* 1 - obey immunity
|
|
|
|
* 2 - allow yourself
|
|
|
|
* 4 - must be alive
|
|
|
|
* 8 - can't be bot
|
|
|
|
*/
|
2007-07-25 18:10:08 +00:00
|
|
|
#define CMDTARGET_OBEY_IMMUNITY (1<<0)
|
2015-02-06 00:32:33 +00:00
|
|
|
#define CMDTARGET_ALLOW_SELF (1<<1)
|
|
|
|
#define CMDTARGET_ONLY_ALIVE (1<<2)
|
|
|
|
#define CMDTARGET_NO_BOTS (1<<3)
|
|
|
|
|
|
|
|
stock cmd_target(id, const arg[], flags = CMDTARGET_OBEY_IMMUNITY)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
new player = find_player("bl", arg);
|
|
|
|
if (player)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (player != find_player("blj", arg))
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
console_print(id, "%L", id, "MORE_CL_MATCHT");
|
2007-03-05 19:30:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
else if ((player = find_player("c", arg)) == 0 && arg[0] == '#' && arg[1])
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
player = find_player("k", str_to_num(arg[1]));
|
2007-03-05 19:30:40 +00:00
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
if (!player)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
console_print(id, "%L", id, "CL_NOT_FOUND");
|
2007-03-05 19:30:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
if (flags & CMDTARGET_OBEY_IMMUNITY)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if ((get_user_flags(player) & ADMIN_IMMUNITY) && ((flags & CMDTARGET_ALLOW_SELF) ? (id != player) : true))
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2014-07-20 10:27:02 +00:00
|
|
|
new imname[MAX_NAME_LENGTH];
|
2015-02-06 00:32:33 +00:00
|
|
|
get_user_name(player, imname, charsmax(imname));
|
|
|
|
console_print(id, "%L", id, "CLIENT_IMM", imname);
|
2007-03-05 19:30:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
if (flags & CMDTARGET_ONLY_ALIVE)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (!is_user_alive(player))
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2014-07-20 10:27:02 +00:00
|
|
|
new imname[MAX_NAME_LENGTH];
|
2015-02-06 00:32:33 +00:00
|
|
|
get_user_name(player, imname, charsmax(imname));
|
|
|
|
console_print(id, "%L", id, "CANT_PERF_DEAD", imname);
|
2007-03-05 19:30:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
if (flags & CMDTARGET_NO_BOTS)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (is_user_bot(player))
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2014-07-20 10:27:02 +00:00
|
|
|
new imname[MAX_NAME_LENGTH];
|
2015-02-06 00:32:33 +00:00
|
|
|
get_user_name(player, imname, charsmax(imname));
|
|
|
|
console_print(id, "%L", id, "CANT_PERF_BOT", imname);
|
2007-03-05 19:30:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
return player;
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2007-05-24 17:11:11 +00:00
|
|
|
/**
|
|
|
|
* Standard method to show activity to clients connected to the server.
|
|
|
|
* This depends on the amx_show_activity cvar. See documentation for more details.
|
|
|
|
*
|
2015-02-06 00:32:33 +00:00
|
|
|
* @param id The user id of the person doing the action.
|
|
|
|
* @param name The name of the person doing the action.
|
|
|
|
* @param fmt The format string to display. Do not put the "ADMIN:" prefix in this.
|
|
|
|
*
|
|
|
|
* @noreturn
|
2007-05-24 17:11:11 +00:00
|
|
|
*/
|
2015-02-06 00:32:33 +00:00
|
|
|
stock show_activity(id, const name[], const fmt[], any:...)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2007-05-24 17:11:11 +00:00
|
|
|
static __amx_show_activity;
|
|
|
|
if (__amx_show_activity == 0)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2007-05-24 17:11:11 +00:00
|
|
|
__amx_show_activity = get_cvar_pointer("amx_show_activity");
|
2015-02-06 00:32:33 +00:00
|
|
|
|
2007-05-24 17:11:11 +00:00
|
|
|
// if still not found, then register the cvar as a dummy
|
|
|
|
if (__amx_show_activity == 0)
|
|
|
|
{
|
2014-07-28 21:33:08 +00:00
|
|
|
__amx_show_activity = register_cvar("amx_show_activity", "2", FCVAR_PROTECTED);
|
2007-05-24 17:11:11 +00:00
|
|
|
}
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
|
2007-05-24 17:11:11 +00:00
|
|
|
new prefix[10];
|
|
|
|
if (is_user_admin(id))
|
|
|
|
{
|
|
|
|
copy(prefix, charsmax(prefix), "ADMIN");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
copy(prefix, charsmax(prefix), "PLAYER");
|
|
|
|
}
|
|
|
|
new buffer[512];
|
2008-03-04 19:18:17 +00:00
|
|
|
vformat(buffer, charsmax(buffer), fmt, 4);
|
2015-02-06 00:32:33 +00:00
|
|
|
|
|
|
|
switch (get_pcvar_num(__amx_show_activity))
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
|
|
|
case 5: // hide name only to admins, show nothing to normal users
|
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
for (new i = 1; i <= MaxClients; i++)
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
|
|
|
if (is_user_connected(i))
|
|
|
|
{
|
|
|
|
if (is_user_admin(i))
|
|
|
|
{
|
|
|
|
client_print(i, print_chat, "%L: %s", i, prefix, buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case 4: // show name only to admins, show nothing to normal users
|
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
for (new i = 1; i <= MaxClients; i++)
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
|
|
|
if (is_user_connected(i))
|
|
|
|
{
|
|
|
|
if (is_user_admin(i))
|
|
|
|
{
|
|
|
|
client_print(i, print_chat, "%L %s: %s", i, prefix, name, buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case 3: // show name only to admins, hide name from normal users
|
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
for (new i = 1; i <= MaxClients; i++)
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
|
|
|
if (is_user_connected(i))
|
|
|
|
{
|
|
|
|
if (is_user_admin(i))
|
|
|
|
{
|
|
|
|
client_print(i, print_chat, "%L %s: %s", i, prefix, name, buffer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client_print(i, print_chat, "%L: %s", i, prefix, buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case 2: // show name to all
|
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
client_print(0, print_chat, "%L %s: %s", LANG_PLAYER, prefix , name , buffer);
|
2007-05-24 17:11:11 +00:00
|
|
|
}
|
|
|
|
case 1: // hide name to all
|
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
client_print(0, print_chat, "%L: %s", LANG_PLAYER, prefix, buffer);
|
2007-05-24 17:11:11 +00:00
|
|
|
}
|
2007-03-05 19:30:40 +00:00
|
|
|
}
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2007-05-24 17:11:11 +00:00
|
|
|
/**
|
2015-02-06 00:32:33 +00:00
|
|
|
* Standard method to show activity to one single client.
|
2007-05-24 17:11:11 +00:00
|
|
|
* This is useful for messages that get pieced together by many language keys.
|
|
|
|
* This depends on the amx_show_activity cvar. See documentation for more details.
|
|
|
|
*
|
2015-02-06 00:32:33 +00:00
|
|
|
* @param idtarget The user id of the person to display to. 0 is invalid.
|
|
|
|
* @param idadmin The user id of the person doing the action.
|
|
|
|
* @param name The name of the person doing the action.
|
|
|
|
* @param fmt The format string to display. Do not put the "ADMIN:" prefix in this.
|
|
|
|
*
|
|
|
|
* @noreturn
|
2007-05-24 17:11:11 +00:00
|
|
|
*/
|
|
|
|
stock show_activity_id(idtarget, idadmin, const name[], const fmt[], any:...)
|
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (idtarget == 0 || !is_user_connected(idtarget))
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __amx_show_activity;
|
|
|
|
if (__amx_show_activity == 0)
|
|
|
|
{
|
|
|
|
__amx_show_activity = get_cvar_pointer("amx_show_activity");
|
2015-02-06 00:32:33 +00:00
|
|
|
|
2007-05-24 17:11:11 +00:00
|
|
|
// if still not found, then register the cvar as a dummy
|
|
|
|
if (__amx_show_activity == 0)
|
|
|
|
{
|
2014-07-28 21:33:08 +00:00
|
|
|
__amx_show_activity = register_cvar("amx_show_activity", "2", FCVAR_PROTECTED);
|
2007-05-24 17:11:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static prefix[10];
|
|
|
|
if (is_user_admin(idadmin))
|
|
|
|
{
|
|
|
|
copy(prefix, charsmax(prefix), "ADMIN");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
copy(prefix, charsmax(prefix), "PLAYER");
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
|
2007-05-24 17:11:11 +00:00
|
|
|
static buffer[512];
|
|
|
|
vformat(buffer, charsmax(buffer), fmt, 5);
|
2015-02-06 00:32:33 +00:00
|
|
|
|
|
|
|
switch (get_pcvar_num(__amx_show_activity))
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
|
|
|
case 5: // hide name only to admins, show nothing to normal users
|
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (is_user_admin(idtarget))
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
|
|
|
client_print(idtarget, print_chat, "%L: %s", idtarget, prefix, buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case 4: // show name only to admins, show nothing to normal users
|
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (is_user_admin(idtarget))
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
|
|
|
client_print(idtarget, print_chat, "%L %s: %s", idtarget, prefix, name, buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case 3: // show name only to admins, hide name from normal users
|
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (is_user_admin(idtarget))
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
|
|
|
client_print(idtarget, print_chat, "%L %s: %s", idtarget, prefix, name, buffer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
client_print(idtarget, print_chat, "%L: %s", idtarget, prefix, buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case 2: // show name to all
|
|
|
|
{
|
|
|
|
client_print(idtarget, print_chat, "%L %s: %s", idtarget, prefix, name, buffer);
|
|
|
|
}
|
|
|
|
case 1: // hide name to all
|
|
|
|
{
|
|
|
|
client_print(idtarget, print_chat, "%L: %s", idtarget, prefix, buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
|
2007-05-24 17:11:11 +00:00
|
|
|
/**
|
|
|
|
* Standard method to show activity to one single client with normal language keys.
|
|
|
|
* These keys need to be in the format of standard AMXX keys:
|
|
|
|
* eg: ADMIN_KICK_1 = ADMIN: kick %s
|
|
|
|
* ADMIN_KICK_2 = ADMIN %s: kick %s
|
|
|
|
* This depends on the amx_show_activity cvar. See documentation for more details.
|
|
|
|
*
|
2015-02-06 00:32:33 +00:00
|
|
|
* @param KeyWithoutName The language key that does not have the name field.
|
|
|
|
* @param KeyWithName The language key that does have the name field.
|
|
|
|
* @param __AdminName The name of the person doing the action.
|
|
|
|
* @extra Pass any extra format arguments for the language key in the variable arguments list.
|
|
|
|
*
|
|
|
|
* @noreturn
|
2007-05-24 17:11:11 +00:00
|
|
|
*/
|
|
|
|
stock show_activity_key(const KeyWithoutName[], const KeyWithName[], const ___AdminName[], any:...)
|
|
|
|
{
|
|
|
|
// The variable gets used via vformat, but the compiler doesn't know that, so it still cries.
|
|
|
|
#pragma unused ___AdminName
|
|
|
|
static __amx_show_activity;
|
|
|
|
if (__amx_show_activity == 0)
|
|
|
|
{
|
|
|
|
__amx_show_activity = get_cvar_pointer("amx_show_activity");
|
2015-02-06 00:32:33 +00:00
|
|
|
|
2007-05-24 17:11:11 +00:00
|
|
|
// if still not found, then register the cvar as a dummy
|
|
|
|
if (__amx_show_activity == 0)
|
|
|
|
{
|
2014-07-28 21:33:08 +00:00
|
|
|
__amx_show_activity = register_cvar("amx_show_activity", "2", FCVAR_PROTECTED);
|
2007-05-24 17:11:11 +00:00
|
|
|
}
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
|
2007-05-24 17:11:11 +00:00
|
|
|
new buffer[512];
|
|
|
|
new keyfmt[256];
|
|
|
|
new i;
|
2015-02-06 00:32:33 +00:00
|
|
|
|
|
|
|
switch (get_pcvar_num(__amx_show_activity))
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
case 5: // hide name to admins, display nothing to normal players
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
while (i++ < MaxClients)
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (is_user_connected(i))
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (is_user_admin(i))
|
|
|
|
{
|
|
|
|
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i);
|
2007-05-24 17:11:11 +00:00
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
// skip the "adminname" argument if not showing name
|
|
|
|
vformat(buffer, charsmax(buffer), keyfmt, 4);
|
|
|
|
client_print(i, print_chat, "%s", buffer);
|
|
|
|
}
|
2007-05-24 17:11:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
case 4: // show name only to admins, display nothing to normal players
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
while (i++ < MaxClients)
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (is_user_connected(i))
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (is_user_admin(i))
|
|
|
|
{
|
|
|
|
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i);
|
|
|
|
vformat(buffer, charsmax(buffer), keyfmt, 3);
|
|
|
|
client_print(i, print_chat, "%s", buffer);
|
|
|
|
}
|
2007-05-24 17:11:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
case 3: // show name only to admins, hide name from normal users
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
while (i++ < MaxClients)
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (is_user_connected(i))
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (is_user_admin(i))
|
|
|
|
{
|
|
|
|
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i);
|
|
|
|
vformat(buffer, charsmax(buffer), keyfmt, 3);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i);
|
|
|
|
|
|
|
|
// skip the "adminname" argument if not showing name
|
|
|
|
vformat(buffer, charsmax(buffer), keyfmt, 4);
|
|
|
|
}
|
|
|
|
client_print(i, print_chat, "%s", buffer);
|
2007-05-24 17:11:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
case 2: // show name to all users
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
while (i++ < MaxClients)
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (is_user_connected(i))
|
|
|
|
{
|
|
|
|
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i);
|
|
|
|
vformat(buffer, charsmax(buffer), keyfmt, 3);
|
|
|
|
client_print(i, print_chat, "%s", buffer);
|
|
|
|
}
|
2007-05-24 17:11:11 +00:00
|
|
|
}
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
case 1: // hide name from all users
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
while (i++ < MaxClients)
|
2007-05-24 17:11:11 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
if (is_user_connected(i))
|
|
|
|
{
|
|
|
|
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i);
|
2007-05-24 17:11:11 +00:00
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
// skip the "adminname" argument if not showing name
|
|
|
|
vformat(buffer, charsmax(buffer), keyfmt, 4);
|
|
|
|
client_print(i, print_chat, "%s", buffer);
|
|
|
|
}
|
2007-05-24 17:11:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-18 17:10:58 +00:00
|
|
|
stock colored_menus()
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2014-10-18 18:04:10 +00:00
|
|
|
static ColoredMenus = -1;
|
2014-10-18 17:10:58 +00:00
|
|
|
|
2014-10-18 18:04:10 +00:00
|
|
|
if (ColoredMenus == -1)
|
2014-10-18 17:10:58 +00:00
|
|
|
{
|
2014-10-18 18:11:10 +00:00
|
|
|
new const ModNames[][] = { "cstrike", "czero", "dmc", "dod", "tfc", "valve" };
|
2014-10-18 18:04:10 +00:00
|
|
|
new ModName[32];
|
2014-10-18 18:11:10 +00:00
|
|
|
|
2014-10-18 18:04:10 +00:00
|
|
|
get_modname(ModName, charsmax(ModName));
|
|
|
|
|
|
|
|
for (new Iterator = 0; Iterator < sizeof(ModNames); Iterator++)
|
|
|
|
{
|
|
|
|
if (equal(ModName, ModNames[Iterator]))
|
|
|
|
{
|
|
|
|
ColoredMenus = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ColoredMenus == -1)
|
|
|
|
ColoredMenus = 0;
|
2014-10-18 17:10:58 +00:00
|
|
|
}
|
2004-07-26 15:07:25 +00:00
|
|
|
|
2014-10-18 18:04:10 +00:00
|
|
|
return ColoredMenus;
|
2004-07-26 15:07:25 +00:00
|
|
|
}
|
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
stock cstrike_running()
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
new mod_name[32];
|
2015-02-06 00:32:33 +00:00
|
|
|
get_modname(mod_name, charsmax(mod_name));
|
2004-07-26 15:07:25 +00:00
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
return (equal(mod_name, "cstrike") || equal(mod_name, "czero") || equal(mod_name, "csv15") || equal(mod_name, "cs13"));
|
2004-07-27 16:42:59 +00:00
|
|
|
}
|
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
stock is_running(const mod[])
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
new mod_name[32];
|
2015-02-06 00:32:33 +00:00
|
|
|
get_modname(mod_name, charsmax(mod_name));
|
2004-07-27 16:42:59 +00:00
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
return equal(mod_name, mod);
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
stock get_basedir(name[], len)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
return get_localinfo("amxx_basedir", name, len);
|
2007-03-05 19:30:40 +00:00
|
|
|
}
|
2004-03-25 13:34:27 +00:00
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
stock get_configsdir(name[], len)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
return get_localinfo("amxx_configsdir", name, len);
|
2007-03-05 19:30:40 +00:00
|
|
|
}
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
stock get_datadir(name[], len)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
return get_localinfo("amxx_datadir", name, len);
|
2007-03-05 19:30:40 +00:00
|
|
|
}
|
2004-06-29 16:38:27 +00:00
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
stock register_menu(const title[], keys, const function[], outside = 0)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
register_menucmd(register_menuid(title, outside), keys, function);
|
2007-03-05 19:30:40 +00:00
|
|
|
}
|
2004-07-31 01:00:20 +00:00
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
/**
|
|
|
|
* Backwards Compatibility
|
|
|
|
* don't use it!
|
|
|
|
*/
|
|
|
|
stock get_customdir(name[], len)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
return get_localinfo("amxx_configsdir", name, len);
|
2007-03-05 19:30:40 +00:00
|
|
|
}
|
2004-10-08 08:36:54 +00:00
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
/**
|
|
|
|
* Add a menu item to Menus Front-End plugin ("amxmodmenu").
|
|
|
|
*
|
|
|
|
* @param MENU_TEXT Text that will be shown for this item in menu.
|
|
|
|
* @param MENU_CMD Command that should be executed to start menu.
|
|
|
|
* @param MENU_ACCESS Access required for menu.
|
|
|
|
* @param MENU_PLUGIN The exact case-insensitive name of plugin holding the menu command.
|
|
|
|
*
|
|
|
|
* @noreturn
|
|
|
|
*/
|
|
|
|
stock AddMenuItem(const MENU_TEXT[], const MENU_CMD[], const MENU_ACCESS, const MENU_PLUGIN[])
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
AddMenuItem_call(MENU_TEXT, MENU_CMD, MENU_ACCESS, MENU_PLUGIN, false);
|
2005-01-15 09:58:51 +00:00
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a menu item to "amx_menu", that should also be accessible by non-admins.
|
|
|
|
*
|
|
|
|
* @param MENU_TEXT Text that will be shown for this item in menu.
|
|
|
|
* @param MENU_CMD Command that should be executed to start menu.
|
|
|
|
* @param MENU_ACCESS Access required for menu.
|
|
|
|
* @param MENU_PLUGIN The exact case-insensitive name of plugin holding the menu command.
|
|
|
|
*
|
|
|
|
* @noreturn
|
|
|
|
*/
|
|
|
|
stock AddClientMenuItem(const MENU_TEXT[], const MENU_CMD[], const MENU_ACCESS, const MENU_PLUGIN[])
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
AddMenuItem_call(MENU_TEXT, MENU_CMD, MENU_ACCESS, MENU_PLUGIN, true);
|
2005-01-15 09:58:51 +00:00
|
|
|
}
|
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
/**
|
|
|
|
* Internal function used by above stocks.
|
|
|
|
*/
|
|
|
|
stock AddMenuItem_call(const MENU_TEXT[], const MENU_CMD[], const MENU_ACCESS, const MENU_PLUGIN[], const bool:ADD_TO_CLIENT_MENU)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
new pluginid = is_plugin_loaded("Menus Front-End");
|
2015-02-06 00:32:33 +00:00
|
|
|
if (pluginid == -1)
|
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
log_amx("Can't add menu item ^"%s^" from plugin ^"%s^" to menu set because the Menus Front-End plugin itself is not loaded!", MENU_TEXT, MENU_PLUGIN);
|
|
|
|
return; // Menus Front-End doesn't exist, return.
|
2004-10-08 08:36:54 +00:00
|
|
|
}
|
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
new filename[64], b[1];
|
2015-02-06 00:32:33 +00:00
|
|
|
get_plugin(pluginid, filename, charsmax(filename), b, charsmax(b), b, charsmax(b), b, charsmax(b), b, charsmax(b));
|
2004-10-08 08:36:54 +00:00
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
new status = callfunc_begin(ADD_TO_CLIENT_MENU ? "AddClientMenu" : "AddMenu", filename);
|
|
|
|
new bool:failed = true;
|
|
|
|
switch (status)
|
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
failed = false;
|
|
|
|
}
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
log_amx("Run time error! (AddMenuItem_call failed)");
|
|
|
|
}
|
|
|
|
case -2:
|
|
|
|
{
|
|
|
|
log_amx("Function not found! (AddMenuItem_call failed)");
|
|
|
|
}
|
|
|
|
case -1:
|
|
|
|
{
|
|
|
|
log_amx("Plugin not found! (AddMenuItem_call failed)");
|
|
|
|
}
|
2004-10-08 08:36:54 +00:00
|
|
|
}
|
|
|
|
if (failed)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2004-10-08 08:53:27 +00:00
|
|
|
// Item text
|
2007-03-05 19:30:40 +00:00
|
|
|
callfunc_push_str(MENU_TEXT);
|
2004-10-08 08:36:54 +00:00
|
|
|
// Cmd
|
2007-03-05 19:30:40 +00:00
|
|
|
callfunc_push_str(MENU_CMD);
|
2004-10-08 08:36:54 +00:00
|
|
|
// Access
|
2007-03-05 19:30:40 +00:00
|
|
|
callfunc_push_int(MENU_ACCESS);
|
2004-10-08 08:53:27 +00:00
|
|
|
// Menu exists in this plugin
|
2007-03-05 19:30:40 +00:00
|
|
|
callfunc_push_str(MENU_PLUGIN);
|
2004-10-08 08:36:54 +00:00
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
callfunc_end();
|
2005-03-30 11:37:41 +00:00
|
|
|
}
|
2005-09-08 15:24:28 +00:00
|
|
|
|
2005-09-08 15:29:31 +00:00
|
|
|
stock constraint_offset(low, high, seed, offset)
|
2005-09-08 15:24:28 +00:00
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
new numElements = high - low + 1;
|
|
|
|
offset += seed - low;
|
2005-09-08 15:24:28 +00:00
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
if (offset >= 0)
|
|
|
|
{
|
|
|
|
return low + (offset % numElements);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return high - (abs(offset) % numElements) + 1;
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
return 0; // Makes the compiler happy -_-
|
2005-09-08 15:24:28 +00:00
|
|
|
}
|
2007-03-09 03:04:40 +00:00
|
|
|
|
2015-02-06 00:32:33 +00:00
|
|
|
/**
|
|
|
|
* Tells if the user has ANY of the provided flags.
|
|
|
|
*
|
|
|
|
* @param id Client index
|
|
|
|
* @param flags Flag string
|
|
|
|
*
|
|
|
|
* @return 1 if the user has ANY of the provided flags, 0 otherwise
|
2007-03-09 03:04:40 +00:00
|
|
|
*/
|
2015-02-06 00:32:33 +00:00
|
|
|
stock has_flag(id, const flags[])
|
2007-03-09 03:04:40 +00:00
|
|
|
{
|
|
|
|
return (get_user_flags(id) & read_flags(flags));
|
|
|
|
}
|
2015-02-06 00:32:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tells if the user has ALL of the provided flags.
|
|
|
|
*
|
|
|
|
* @param id Client index
|
|
|
|
* @param flags Flag string
|
|
|
|
*
|
|
|
|
* @return 1 if the user has ALL of the provided flags, 0 otherwise
|
2007-03-09 03:04:40 +00:00
|
|
|
*/
|
2015-02-06 00:32:33 +00:00
|
|
|
stock has_all_flags(id, const flags[])
|
2007-03-09 03:04:40 +00:00
|
|
|
{
|
2015-02-06 00:32:33 +00:00
|
|
|
new FlagsNumber = read_flags(flags);
|
|
|
|
return ((get_user_flags(id) & FlagsNumber) == FlagsNumber);
|
2007-03-09 03:04:40 +00:00
|
|
|
}
|
2014-10-24 18:10:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets a client's menu.
|
|
|
|
*
|
|
|
|
* @note This is just a wrapper around show_menu for the sake of readability.
|
|
|
|
*
|
|
|
|
* @param index Client to reset menu to, use 0 to reset to all clients
|
2015-02-06 00:32:33 +00:00
|
|
|
*
|
|
|
|
* @noreturn
|
2014-10-24 18:10:10 +00:00
|
|
|
*/
|
|
|
|
stock reset_menu(index)
|
|
|
|
{
|
|
|
|
show_menu(index, 0, "", 0);
|
|
|
|
}
|