- added AddTargetsToMenu2() for using COMMAND_FILTER flags
- fixed amb1350 - sm_voteban/menu ban on fake clients would crash - fake clients can no longer be banned and do not appear on ban menus --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401838
This commit is contained in:
parent
89ac3a14ba
commit
4e07200cfb
@ -256,6 +256,11 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
|
|||||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pPlayer->IsFakeClient())
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Cannot ban fake client %d", client);
|
||||||
|
}
|
||||||
|
|
||||||
pContext->LocalToString(params[4], &ban_reason);
|
pContext->LocalToString(params[4], &ban_reason);
|
||||||
pContext->LocalToString(params[5], (char **)&kick_message);
|
pContext->LocalToString(params[5], (char **)&kick_message);
|
||||||
pContext->LocalToString(params[6], &ban_cmd);
|
pContext->LocalToString(params[6], &ban_cmd);
|
||||||
|
@ -61,6 +61,7 @@ public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max)
|
|||||||
{
|
{
|
||||||
CreateNative("GetAdminTopMenu", __GetAdminTopMenu);
|
CreateNative("GetAdminTopMenu", __GetAdminTopMenu);
|
||||||
CreateNative("AddTargetsToMenu", __AddTargetsToMenu);
|
CreateNative("AddTargetsToMenu", __AddTargetsToMenu);
|
||||||
|
CreateNative("AddTargetsToMenu2", __AddTargetsToMenu2);
|
||||||
RegPluginLibrary("adminmenu");
|
RegPluginLibrary("adminmenu");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -181,6 +182,11 @@ public __AddTargetsToMenu(Handle:plugin, numParams)
|
|||||||
return UTIL_AddTargetsToMenu(GetNativeCell(1), GetNativeCell(2), GetNativeCell(3), alive_only);
|
return UTIL_AddTargetsToMenu(GetNativeCell(1), GetNativeCell(2), GetNativeCell(3), alive_only);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public __AddTargetsToMenu2(Handle:plugin, numParams)
|
||||||
|
{
|
||||||
|
return UTIL_AddTargetsToMenu2(GetNativeCell(1), GetNativeCell(2), GetNativeCell(3));
|
||||||
|
}
|
||||||
|
|
||||||
public Action:Command_DisplayMenu(client, args)
|
public Action:Command_DisplayMenu(client, args)
|
||||||
{
|
{
|
||||||
if (client == 0)
|
if (client == 0)
|
||||||
@ -194,7 +200,7 @@ public Action:Command_DisplayMenu(client, args)
|
|||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
stock UTIL_AddTargetsToMenu(Handle:menu, source_client, bool:in_game_only, bool:alive_only)
|
stock UTIL_AddTargetsToMenu2(Handle:menu, source_client, flags)
|
||||||
{
|
{
|
||||||
new max_clients = GetMaxClients();
|
new max_clients = GetMaxClients();
|
||||||
decl String:user_id[12];
|
decl String:user_id[12];
|
||||||
@ -210,17 +216,34 @@ stock UTIL_AddTargetsToMenu(Handle:menu, source_client, bool:in_game_only, bool:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_game_only && !IsClientInGame(i))
|
PrintToServer("%d, %d, %d", i, flags, IsFakeClient(i));
|
||||||
|
|
||||||
|
if (((flags & COMMAND_FILTER_NO_BOTS) == COMMAND_FILTER_NO_BOTS)
|
||||||
|
&& IsFakeClient(i))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alive_only && !IsPlayerAlive(i))
|
if (((flags & COMMAND_FILTER_CONNECTED) != COMMAND_FILTER_CONNECTED)
|
||||||
|
&& !IsClientInGame(i))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source_client && !CanUserTarget(source_client, i))
|
if (((flags & COMMAND_FILTER_ALIVE) == COMMAND_FILTER_ALIVE)
|
||||||
|
&& !IsPlayerAlive(i))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((flags & COMMAND_FILTER_DEAD) == COMMAND_FILTER_DEAD)
|
||||||
|
&& IsPlayerAlive(i))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((source_client && ((flags & COMMAND_FILTER_NO_IMMUNITY) != COMMAND_FILTER_NO_IMMUNITY))
|
||||||
|
&& !CanUserTarget(source_client, i))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -235,3 +258,20 @@ stock UTIL_AddTargetsToMenu(Handle:menu, source_client, bool:in_game_only, bool:
|
|||||||
return num_clients;
|
return num_clients;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stock UTIL_AddTargetsToMenu(Handle:menu, source_client, bool:in_game_only, bool:alive_only)
|
||||||
|
{
|
||||||
|
new flags = 0;
|
||||||
|
|
||||||
|
if (!in_game_only)
|
||||||
|
{
|
||||||
|
flags |= COMMAND_FILTER_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alive_only)
|
||||||
|
{
|
||||||
|
flags |= COMMAND_FILTER_ALIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return UTIL_AddTargetsToMenu2(menu, source_client, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ DisplayBanTargetMenu(client)
|
|||||||
SetMenuTitle(menu, title);
|
SetMenuTitle(menu, title);
|
||||||
SetMenuExitBackButton(menu, true);
|
SetMenuExitBackButton(menu, true);
|
||||||
|
|
||||||
AddTargetsToMenu(menu, client, false, false);
|
AddTargetsToMenu2(menu, client, COMMAND_FILTER_NO_BOTS|COMMAND_FILTER_CONNECTED);
|
||||||
|
|
||||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ public Action:Command_Voteban(client, args)
|
|||||||
client,
|
client,
|
||||||
target_list,
|
target_list,
|
||||||
MAXPLAYERS,
|
MAXPLAYERS,
|
||||||
COMMAND_FILTER_NO_MULTI,
|
COMMAND_FILTER_NO_MULTI|COMMAND_FILTER_NO_BOTS,
|
||||||
target_name,
|
target_name,
|
||||||
sizeof(target_name),
|
sizeof(target_name),
|
||||||
tn_is_ml)) <= 0)
|
tn_is_ml)) <= 0)
|
||||||
|
@ -94,7 +94,23 @@ native Handle:GetAdminTopMenu();
|
|||||||
* @param alive_only True to only select alive players.
|
* @param alive_only True to only select alive players.
|
||||||
* @return Number of clients added.
|
* @return Number of clients added.
|
||||||
*/
|
*/
|
||||||
native AddTargetsToMenu(Handle:menu, source_client, bool:in_game_only=true, bool:alive_only=false);
|
native AddTargetsToMenu(Handle:menu,
|
||||||
|
source_client,
|
||||||
|
bool:in_game_only=true,
|
||||||
|
bool:alive_only=false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds targets to an admin menu.
|
||||||
|
*
|
||||||
|
* Each client is displayed as: name (userid)
|
||||||
|
* Each item contains the userid as a string for its info.
|
||||||
|
*
|
||||||
|
* @param menu Menu Handle.
|
||||||
|
* @param source_client Source client, or 0 to ignore immunity.
|
||||||
|
* @param flags COMMAND_FILTER flags from commandfilters.inc.
|
||||||
|
* @return Number of clients added.
|
||||||
|
*/
|
||||||
|
native AddTargetsToMenu2(Handle:menu, source_client, flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-displays the admin menu to a client after selecting an item.
|
* Re-displays the admin menu to a client after selecting an item.
|
||||||
@ -132,5 +148,6 @@ public __pl_adminmenu_SetNTVOptional()
|
|||||||
{
|
{
|
||||||
MarkNativeAsOptional("GetAdminTopMenu");
|
MarkNativeAsOptional("GetAdminTopMenu");
|
||||||
MarkNativeAsOptional("AddTargetsToMenu");
|
MarkNativeAsOptional("AddTargetsToMenu");
|
||||||
|
MarkNativeAsOptional("AddTargetsToMenu2");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,21 +37,21 @@
|
|||||||
|
|
||||||
#define MAX_TARGET_LENGTH 64
|
#define MAX_TARGET_LENGTH 64
|
||||||
|
|
||||||
#define COMMAND_FILTER_ALIVE (1<<0) /* Only allow alive players */
|
#define COMMAND_FILTER_ALIVE (1<<0) /**< Only allow alive players */
|
||||||
#define COMMAND_FILTER_DEAD (1<<1) /* Only filter dead players */
|
#define COMMAND_FILTER_DEAD (1<<1) /**< Only filter dead players */
|
||||||
#define COMMAND_FILTER_CONNECTED (1<<2) /* Allow players not fully in-game */
|
#define COMMAND_FILTER_CONNECTED (1<<2) /**< Allow players not fully in-game */
|
||||||
#define COMMAND_FILTER_NO_IMMUNITY (1<<3) /* Ignore immunity rules */
|
#define COMMAND_FILTER_NO_IMMUNITY (1<<3) /**< Ignore immunity rules */
|
||||||
#define COMMAND_FILTER_NO_MULTI (1<<4) /* Do not allow multiple target patterns */
|
#define COMMAND_FILTER_NO_MULTI (1<<4) /**< Do not allow multiple target patterns */
|
||||||
#define COMMAND_FILTER_NO_BOTS (1<<5) /* Do not allow bots to be targetted */
|
#define COMMAND_FILTER_NO_BOTS (1<<5) /**< Do not allow bots to be targetted */
|
||||||
|
|
||||||
#define COMMAND_TARGET_NONE 0 /* No target was found */
|
#define COMMAND_TARGET_NONE 0 /**< No target was found */
|
||||||
#define COMMAND_TARGET_NOT_ALIVE -1 /* Single client is not alive */
|
#define COMMAND_TARGET_NOT_ALIVE -1 /**< Single client is not alive */
|
||||||
#define COMMAND_TARGET_NOT_DEAD -2 /* Single client is not dead */
|
#define COMMAND_TARGET_NOT_DEAD -2 /**< Single client is not dead */
|
||||||
#define COMMAND_TARGET_NOT_IN_GAME -3 /* Single client is not in game */
|
#define COMMAND_TARGET_NOT_IN_GAME -3 /**< Single client is not in game */
|
||||||
#define COMMAND_TARGET_IMMUNE -4 /* Single client is immune */
|
#define COMMAND_TARGET_IMMUNE -4 /**< Single client is immune */
|
||||||
#define COMMAND_TARGET_EMPTY_FILTER -5 /* A multi-filter (such as @all) had no targets */
|
#define COMMAND_TARGET_EMPTY_FILTER -5 /**< A multi-filter (such as @all) had no targets */
|
||||||
#define COMMAND_TARGET_NOT_HUMAN -6 /* Target was not human */
|
#define COMMAND_TARGET_NOT_HUMAN -6 /**< Target was not human */
|
||||||
#define COMMAND_TARGET_AMBIGUOUS -7 /* Partial name had too many targets */
|
#define COMMAND_TARGET_AMBIGUOUS -7 /**< Partial name had too many targets */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes a generic command target string, and resolves it to a list
|
* Processes a generic command target string, and resolves it to a list
|
||||||
|
Loading…
Reference in New Issue
Block a user