View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-09-2023 , 00:13   Re: Question about native : get_players
Reply With Quote #4

Why don't you just look at the native to see what it does?
PHP Code:
static cell AMX_NATIVE_CALL get_players(AMX *amxcell *params/* 4 param */
{
    
int iNum 0;
    
int ilen;
    
charsptemp get_amxstring(amxparams[3], 0ilen);
    
int flags UTIL_ReadFlags(sptemp);

    
cell *aPlayers get_amxaddr(amxparams[1]);
    
cell *iMax get_amxaddr(amxparams[2]);

    
int team 0;

    if (
flags 48)
    {
        
sptemp get_amxstring(amxparams[4], 0ilen);

        if (
flags 16)
        {
            if (
flags 64)
                
team g_teamsIds.findTeamId(sptemp);
            else
                
team g_teamsIds.findTeamIdCase(sptemp);
        }
    }

    for (
int i 1<= gpGlobals->maxClients; ++i)
    {
        
CPlayerpPlayer 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 (
stristr(pPlayer->name.chars(), sptemp) == NULL)
                        continue;
                }
                else if (
strstr(pPlayer->name.chars(), sptemp) == NULL)
                    continue;
            }
            
aPlayers[iNum++] = i;
        }
    }

    *
iMax iNum;
    
    return 
1;

__________________
Bugsy is offline