Quote:
Originally Posted by Jhob94
I donÂ’t think youÂ’ve read the cpp of is_user_alive and is_user_connected so i will ignore you from now on
|
And we think you've not read the cpp of get_players:
PHP Code:
static cell AMX_NATIVE_CALL get_players(AMX *amx, cell *params) /* 4 param */
{
int iNum = 0;
int ilen;
char* sptemp = get_amxstring(amx, params[3], 0, ilen);
int flags = UTIL_ReadFlags(sptemp);
cell *aPlayers = get_amxaddr(amx, params[1]);
cell *iMax = get_amxaddr(amx, params[2]);
int team = 0;
if (flags & 48)
{
sptemp = get_amxstring(amx, params[4], 0, ilen);
if (flags & 16)
{
if (flags & 64)
team = g_teamsIds.findTeamId(sptemp);
else
team = g_teamsIds.findTeamIdCase(sptemp);
}
}
for (int i = 1; i <= gpGlobals->maxClients; ++i)
{
CPlayer* pPlayer = GET_PLAYER_POINTER_I(i);
if (pPlayer->ingame || ((flags & 256) && pPlayer->initialized))
{
if (pPlayer->IsAlive() ? (flags & 2) : (flags & 1))
continue;
if (pPlayer->IsBot() ? (flags & 4) : (flags & 8))
continue;
if ((flags & 16) && (pPlayer->teamId != team))
continue;
if ((flags & 128) && (pPlayer->pEdict->v.flags & FL_PROXY))
continue;
if (flags & 32)
{
if (flags & 64)
{
if (utf8stristr(pPlayer->name.chars(), sptemp) == NULL)
continue;
}
else if (strstr(pPlayer->name.chars(), sptemp) == NULL)
continue;
}
aPlayers[iNum++] = i;
}
}
*iMax = iNum;
return 1;
}
What you told about
get_players:
Quote:
Originally Posted by Jhob94
with the computers we have today this isn't a problem.
|
get_user_team:
PHP Code:
static cell AMX_NATIVE_CALL get_user_team(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
if (index < 1 || index > gpGlobals->maxClients)
return -1;
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame)
{
// SidLuke, DoD fix
if (g_bmod_dod)
{
int iTeam = pPlayer->pEdict->v.team;
if (params[3])
{
const char *szTeam = "";
switch (iTeam)
{
case 1:
szTeam = "Allies";
break;
case 2:
szTeam = "Axis";
break;
}
set_amxstring(amx, params[2], szTeam, params[3]);
}
return iTeam;
}
//
if (params[3])
{
set_amxstring(amx, params[2], pPlayer->team.chars(), params[3]);
}
return pPlayer->teamId;
}
return -1;
}
Again, your conversations are arbitrary, have no fundament.
They're eliminating the sense of each other.
You care about
get_user_team in a topic, which has no for loop,
and about
get_players which has a for loop and complex checks, you say it's not a problem.
About
is_user_alive and the two other natives, the CPU time required will be obviously higher compared to a cached value check:
PHP Code:
static cell AMX_NATIVE_CALL is_user_alive(AMX *amx, cell *params) /* 1 param */
{
int index = params[1];
if (index < 1 || index > gpGlobals->maxClients)
{
return FALSE;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (!pPlayer->ingame)
{
return FALSE;
}
if (g_bmod_tfc)
{
edict_t *e = pPlayer->pEdict;
if (e->v.flags & FL_SPECTATOR ||
(!e->v.team || !e->v.playerclass))
{
return FALSE;
}
}
return pPlayer->IsAlive() ? TRUE : FALSE;
}
PHP Code:
If(Alive[id])
{
something
}
-
__________________