Merge pull request #126 from Arkshine/feature-find-player-engclient_print

Allow some natives to be used on connecting players (bug 6229).
This commit is contained in:
Vincent Herbet 2014-08-19 18:35:52 +02:00
commit bd08cc5126
2 changed files with 10 additions and 6 deletions

View File

@ -132,6 +132,7 @@ static cell AMX_NATIVE_CALL engclient_print(AMX *amx, cell *params) /* 3 param *
{ {
int len = 0; int len = 0;
char *msg; char *msg;
PRINT_TYPE type = (PRINT_TYPE)params[2];
if (params[1] == 0) 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); CPlayer* pPlayer = GET_PLAYER_POINTER_I(i);
if (pPlayer->ingame) if ((type == print_console && pPlayer->initialized) || pPlayer->ingame)
{ {
g_langMngr.SetDefLang(i); g_langMngr.SetDefLang(i);
msg = format_amxstring(amx, params, 3, len); msg = format_amxstring(amx, params, 3, len);
msg[len++] = '\n'; msg[len++] = '\n';
msg[len] = 0; msg[len] = 0;
CLIENT_PRINT(pPlayer->pEdict, (PRINT_TYPE)(int)params[2], msg); CLIENT_PRINT(pPlayer->pEdict, type, msg);
} }
} }
} else { } 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); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame) if ((type == print_console && pPlayer->initialized) || pPlayer->ingame)
{ {
g_langMngr.SetDefLang(index); g_langMngr.SetDefLang(index);
msg = format_amxstring(amx, params, 3, len); msg = format_amxstring(amx, params, 3, len);
msg[len++] = '\n'; msg[len++] = '\n';
msg[len] = 0; msg[len] = 0;
CLIENT_PRINT(pPlayer->pEdict, (PRINT_TYPE)(int)params[2], msg); CLIENT_PRINT(pPlayer->pEdict, type, msg);
} }
} }
@ -2260,7 +2261,7 @@ static cell AMX_NATIVE_CALL get_players(AMX *amx, cell *params) /* 4 param */
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CPlayer* pPlayer = GET_PLAYER_POINTER_I(i); CPlayer* pPlayer = GET_PLAYER_POINTER_I(i);
if (pPlayer->ingame) if (pPlayer->ingame || ((flags & 256) && pPlayer->initialized))
{ {
if (pPlayer->IsAlive() ? (flags & 2) : (flags & 1)) if (pPlayer->IsAlive() ? (flags & 2) : (flags & 1))
continue; continue;
@ -2316,7 +2317,7 @@ static cell AMX_NATIVE_CALL find_player(AMX *amx, cell *params) /* 1 param */
{ {
CPlayer* pPlayer = GET_PLAYER_POINTER_I(i); CPlayer* pPlayer = GET_PLAYER_POINTER_I(i);
if (pPlayer->ingame) if (pPlayer->ingame || ((flags & 4096) && pPlayer->initialized))
{ {
if (pPlayer->IsAlive() ? (flags & 64) : (flags & 32)) if (pPlayer->IsAlive() ? (flags & 64) : (flags & 32))
continue; continue;

View File

@ -1215,6 +1215,7 @@ native get_playersnum(flag=0);
* "f" - match with part of name * "f" - match with part of name
* "g" - match case insensitive * "g" - match case insensitive
* "h" - do not include HLTV proxies * "h" - do not include HLTV proxies
* "i" - include connecting clients
* @param team String to match against if the "e" or "f" flag is specified * @param team String to match against if the "e" or "f" flag is specified
* *
* @noreturn * @noreturn
@ -1301,8 +1302,10 @@ native get_flags(flags, output[], len);
* "j" - return last matched client instead of the first * "j" - return last matched client instead of the first
* "k" - match with userid * "k" - match with userid
* "l" - match case insensitively * "l" - match case insensitively
* "m" - include connecting clients
* @param ... String to match against (integer if "k" flag is specified) * @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[], ...); native find_player(const flags[], ...);