Quote:
Originally Posted by HamletEagle
get_players will check every time, it does not use cached data. Using cached data would not make much sense, as different calls to get_players could specify different flags so the native would still need to iterate over the cache and filter it.
|
thank u sir .
i think it does only a single check which is the : flags check .
any other data had been pre-prepared and cached before the native call started , it may looks like this :
Instant calculations ,
Code:
get_players( ......)
{
new x,count;
while (x=find_player(given flags)) players[count++]=x;
//....
//....
and the pre-cahed data which had been calculated before ,
Code:
on_player_death(id)
{
flags[id][0]=false ; // set the related to "a" bool to false or null
flags[id][1]=true; //set b flag bool
}
on_player_connect(id)
{
P_index[Hello++]=id;
flags[id][8]=true; // i flag
flags[id][is_user_bot?3:2]=true // c,d flags
}
on_client_change_team(id)
{
...
...
...
my question was to ensure if its a good idea to use this native inside a repeated timer or not ,cuze i think native does only 3 short loops instantly :
#1-loop : from 0 to max avaliable client in server (depends on pre-prepared data optimization and integer "Hello")
#2-loop : general falgs loop from "a" to "i"
#3-loop : number of given flag to check - "aec" for example + a very simple string check in case "e" or "f"
the second and third loops might be mixed by bits method : if (flags&a)
as a result : i think it is an ideal Native to call if only if it was a one-time call , because checking a flag bits/bool for a player is too much easier than manual instant checks : (is_user_alive(),is_use_connected.....) , here is the proof :
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 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (g_bmod_tfc)
{
edict_t *e = pPlayer->pEdict;
if (e->v.flags & FL_SPECTATOR ||
(!e->v.team || !e->v.playerclass))
{
return 0;
}
}
return ((pPlayer->ingame && pPlayer->IsAlive()) ? 1 : 0);
}
while instant check of a single flag looks like this
Code:
check_flag(id,x)
{
return flags[id][x];
//return flags[id]&x;
}
Finally, I chose another method. If you have any advice related to the attached file, I am ready to listen .
thank u again , sir .