From 76378fd5d0083986bf1328cd3b9afdd8c885c9b5 Mon Sep 17 00:00:00 2001 From: justgo97 Date: Thu, 30 Aug 2018 17:43:05 +0100 Subject: [PATCH] Add get_playersnum_ex (#517) * Allow get_players to get the players num only * used empty brackets instead of zero * Add get_playersnum_ex stock to amxmisc.inc * Added missing empty brackets * Remove brackets from get_players * Fixed a typo in function description * Change letters to flags in get_playersnum_ex description --- plugins/include/amxmisc.inc | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/plugins/include/amxmisc.inc b/plugins/include/amxmisc.inc index 772b7f00..96fb92a8 100755 --- a/plugins/include/amxmisc.inc +++ b/plugins/include/amxmisc.inc @@ -863,9 +863,37 @@ stock set_task_ex(Float:time, const function[], id = 0, const any:parameter[] = * * @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 team[] = "") { new strFlags[10]; get_flags(_:flags, strFlags, charsmax(strFlags)); get_players(players, num, strFlags, team); } + +/** + * Returns the number of clients on the server that match the specified flags. + * + * @note Example retrieving all alive CTs: + * new AliveCt = get_playersnum_ex(GetPlayers_ExcludeDead | GetPlayers_MatchTeam, "CT") + * + * @param flags Optional filtering flags (enum GetPlayersFlags); valid flags are: + * GetPlayers_None - No filter (Default) + * GetPlayers_ExcludeDead - do not include dead clients + * GetPlayers_ExcludeAlive - do not include alive clients + * GetPlayers_ExcludeBots - do not include bots + * GetPlayers_ExcludeHuman - do not include human clients + * GetPlayers_MatchTeam - match with team + * GetPlayers_MatchNameSubstring - match with part of name + * 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 + * + * @return Number of clients on the server that match the specified flags + */ +stock get_playersnum_ex(GetPlayersFlags:flags = GetPlayers_None, const team[] = "") +{ + new PlayersNum; + get_players_ex(_, PlayersNum, flags, team); + return PlayersNum; +}