From 33c0a676fd98b00f9a0978f961526cfee7e1c187 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Sun, 17 Aug 2014 23:31:46 +0200 Subject: [PATCH 1/4] Allow find_player() and engclient_print() (in console) to be used on connecting players (bug 6229). --- amxmodx/amxmodx.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index a22422a0..c473ec18 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -132,6 +132,7 @@ static cell AMX_NATIVE_CALL engclient_print(AMX *amx, cell *params) /* 3 param * { int len = 0; char *msg; + PRINT_TYPE type = (PRINT_TYPE)params[2]; if (params[1] == 0) { @@ -139,13 +140,13 @@ static cell AMX_NATIVE_CALL engclient_print(AMX *amx, cell *params) /* 3 param * { CPlayer* pPlayer = GET_PLAYER_POINTER_I(i); - if (pPlayer->ingame) + if ((type == print_console && pPlayer->initialized) || pPlayer->ingame) { g_langMngr.SetDefLang(i); msg = format_amxstring(amx, params, 3, len); msg[len++] = '\n'; msg[len] = 0; - CLIENT_PRINT(pPlayer->pEdict, (PRINT_TYPE)(int)params[2], msg); + CLIENT_PRINT(pPlayer->pEdict, type, msg); } } } else { @@ -159,13 +160,13 @@ static cell AMX_NATIVE_CALL engclient_print(AMX *amx, cell *params) /* 3 param * CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); - if (pPlayer->ingame) + if ((type == print_console && pPlayer->initialized) || pPlayer->ingame) { g_langMngr.SetDefLang(index); msg = format_amxstring(amx, params, 3, len); msg[len++] = '\n'; msg[len] = 0; - CLIENT_PRINT(pPlayer->pEdict, (PRINT_TYPE)(int)params[2], msg); + CLIENT_PRINT(pPlayer->pEdict, type, msg); } } @@ -2316,7 +2317,7 @@ static cell AMX_NATIVE_CALL find_player(AMX *amx, cell *params) /* 1 param */ { CPlayer* pPlayer = GET_PLAYER_POINTER_I(i); - if (pPlayer->ingame) + if (pPlayer->initialized) { if (pPlayer->IsAlive() ? (flags & 64) : (flags & 32)) continue; From 76811b7b845b29cfb184ab33c8d23950bacb2f56 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Tue, 19 Aug 2014 10:08:25 +0200 Subject: [PATCH 2/4] Allow get_players() as well. --- amxmodx/amxmodx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index c473ec18..367a6c06 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -2261,7 +2261,7 @@ static cell AMX_NATIVE_CALL get_players(AMX *amx, cell *params) /* 4 param */ for (int i = 1; i <= gpGlobals->maxClients; ++i) { CPlayer* pPlayer = GET_PLAYER_POINTER_I(i); - if (pPlayer->ingame) + if (pPlayer->initialized) { if (pPlayer->IsAlive() ? (flags & 2) : (flags & 1)) continue; From 68aec7eec0f8a9f67a42305675eae51d4f900821 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Tue, 19 Aug 2014 15:39:06 +0200 Subject: [PATCH 3/4] Use new flags in get_players/find_player instead to avoid breakage. --- amxmodx/amxmodx.cpp | 4 ++-- plugins/include/amxmodx.inc | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index 367a6c06..fb78ed6d 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -2261,7 +2261,7 @@ static cell AMX_NATIVE_CALL get_players(AMX *amx, cell *params) /* 4 param */ for (int i = 1; i <= gpGlobals->maxClients; ++i) { CPlayer* pPlayer = GET_PLAYER_POINTER_I(i); - if (pPlayer->initialized) + if (((flags & 256) && pPlayer->initialized) || pPlayer->ingame) { if (pPlayer->IsAlive() ? (flags & 2) : (flags & 1)) continue; @@ -2317,7 +2317,7 @@ static cell AMX_NATIVE_CALL find_player(AMX *amx, cell *params) /* 1 param */ { CPlayer* pPlayer = GET_PLAYER_POINTER_I(i); - if (pPlayer->initialized) + if (((flags & 4096) && pPlayer->initialized) || pPlayer->ingame) { if (pPlayer->IsAlive() ? (flags & 64) : (flags & 32)) continue; diff --git a/plugins/include/amxmodx.inc b/plugins/include/amxmodx.inc index 7ca7a418..dd86e3b5 100755 --- a/plugins/include/amxmodx.inc +++ b/plugins/include/amxmodx.inc @@ -1215,6 +1215,7 @@ native get_playersnum(flag=0); * "f" - match with part of name * "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 * * @noreturn @@ -1301,8 +1302,10 @@ native get_flags(flags, output[], len); * "j" - return last matched client instead of the first * "k" - match with userid * "l" - match case insensitively + * "m" - include connecting clients * @param ... String to match against (integer if "k" flag is specified) * + * @return Client index, or 0 if no client was found */ native find_player(const flags[], ...); From bf23890a34a0c844a5be7339378b163d46f21eff Mon Sep 17 00:00:00 2001 From: Arkshine Date: Tue, 19 Aug 2014 18:25:00 +0200 Subject: [PATCH 4/4] Reverse condition for clarity and to make Nextra happy! --- amxmodx/amxmodx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index fb78ed6d..d1695dcb 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -2261,7 +2261,7 @@ static cell AMX_NATIVE_CALL get_players(AMX *amx, cell *params) /* 4 param */ for (int i = 1; i <= gpGlobals->maxClients; ++i) { CPlayer* pPlayer = GET_PLAYER_POINTER_I(i); - if (((flags & 256) && pPlayer->initialized) || pPlayer->ingame) + if (pPlayer->ingame || ((flags & 256) && pPlayer->initialized)) { if (pPlayer->IsAlive() ? (flags & 2) : (flags & 1)) continue; @@ -2317,7 +2317,7 @@ static cell AMX_NATIVE_CALL find_player(AMX *amx, cell *params) /* 1 param */ { CPlayer* pPlayer = GET_PLAYER_POINTER_I(i); - if (((flags & 4096) && pPlayer->initialized) || pPlayer->ingame) + if (pPlayer->ingame || ((flags & 4096) && pPlayer->initialized)) { if (pPlayer->IsAlive() ? (flags & 64) : (flags & 32)) continue;