Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'j' and 'k' flags in get_players for matching with admin flags #476

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
11 changes: 11 additions & 0 deletions amxmodx/amxmodx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2263,6 +2263,7 @@ static cell AMX_NATIVE_CALL get_players(AMX *amx, cell *params) /* 4 param */
{
int iNum = 0;
int ilen;
int pflags = 0;
char* sptemp = get_amxstring(amx, params[3], 0, ilen);
int flags = UTIL_ReadFlags(sptemp);

Expand All @@ -2283,6 +2284,12 @@ static cell AMX_NATIVE_CALL get_players(AMX *amx, cell *params) /* 4 param */
team = g_teamsIds.findTeamIdCase(sptemp);
}
}

if ((flags & 512) || (flags & 1024))
{
sptemp = get_amxstring(amx, params[4], 0, ilen);
pflags = UTIL_ReadFlags(sptemp);
}

for (int i = 1; i <= gpGlobals->maxClients; ++i)
{
Expand All @@ -2297,6 +2304,10 @@ static cell AMX_NATIVE_CALL get_players(AMX *amx, cell *params) /* 4 param */
continue;
if ((flags & 128) && (pPlayer->pEdict->v.flags & FL_PROXY))
continue;
if ((flags & 512) && ((pPlayer->flags[0] & pflags) != pflags))
continue;
if ((flags & 1024) && (!(pPlayer->flags[0] & pflags)))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add consts for all flags?

continue;
if (flags & 32)
{
if (flags & 64)
Expand Down
4 changes: 3 additions & 1 deletion plugins/include/amxconst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,9 @@ enum GetPlayersFlags (<<= 1)
GetPlayers_MatchNameSubstring, // Match with part of name
GetPlayers_CaseInsensitive, // Match case insensitive
GetPlayers_ExcludeHLTV, // Do not include HLTV proxies
GetPlayers_IncludeConnecting // Include connecting clients
GetPlayers_IncludeConnecting, // Include connecting clients
GetPlayers_MatchAllFlags, // Match with all of the specified admin flags
GetPlayers_MatchAnyFlags // Match with any of the specified admin flags
};

/**
Expand Down
18 changes: 11 additions & 7 deletions plugins/include/amxmisc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -859,15 +859,17 @@ stock set_task_ex(Float:time, const function[], id = 0, const any:parameter[] =
* GetPlayers_CaseInsensitive - match case insensitive
* GetPlayers_ExcludeHLTV - do not include HLTV proxies
* GetPlayers_IncludeConnecting - include connecting clients
* @param team String to match against if the "e" or "f" flag is specified
* GetPlayers_MatchAllFlags - match with all of the specified admin flags
* GetPlayers_MatchAnyFlags - match with any of the specified admin flags
* @param string String to match against if a flag that demands additional information is specified
*
* @noreturn
*/
stock get_players_ex(players[MAX_PLAYERS] = {}, &num, GetPlayersFlags:flags = GetPlayers_None, const team[] = "")
stock get_players_ex(players[MAX_PLAYERS] = {}, &num, GetPlayersFlags:flags = GetPlayers_None, const string[] = "")
{
new strFlags[10];
new strFlags[12];
get_flags(_:flags, strFlags, charsmax(strFlags));
get_players(players, num, strFlags, team);
get_players(players, num, strFlags, string);
}

/**
Expand All @@ -887,13 +889,15 @@ stock get_players_ex(players[MAX_PLAYERS] = {}, &num, GetPlayersFlags:flags = Ge
* GetPlayers_CaseInsensitive - match case insensitive
* GetPlayers_ExcludeHLTV - do not include HLTV proxies
* GetPlayers_IncludeConnecting - include connecting clients
* @param team String to match against if the GetPlayers_MatchTeam or GetPlayers_MatchNameSubstring flag is specified
* GetPlayers_MatchAllFlags - match with all of the specified admin flags
* GetPlayers_MatchAnyFlags - match with any of the specified admin flags
* @param string String to match against if a flag that demands additional information is specified
*
* @return Number of clients on the server that match the specified flags
*/
stock get_playersnum_ex(GetPlayersFlags:flags = GetPlayers_None, const team[] = "")
stock get_playersnum_ex(GetPlayersFlags:flags = GetPlayers_None, const string[] = "")
{
new PlayersNum;
get_players_ex(_, PlayersNum, flags, team);
get_players_ex(_, PlayersNum, flags, string);
return PlayersNum;
}
4 changes: 3 additions & 1 deletion plugins/include/amxmodx.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,9 @@ native get_playersnum(flag = 0);
* "g" - match case insensitive
* "h" - do not include HLTV proxies
* "i" - include connecting clients
* @param team String to match against if the "e" or "f" flag is specified
* "j" - match with all of the specified admin flags
* "k" - match with any of the specified admin flags
* @param team String to match against if the "e", "f", "j" or "k" flag is specified
*
* @noreturn
*/
Expand Down