Thread: Optimize Plugin
View Single Post
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-17-2018 , 17:57   Re: Optimize Plugin
Reply With Quote #21

Quote:
Originally Posted by E1_531G View Post
if(is_user_alive(id)) - if true, player is connected and alive.
if(is_user_connected(id) && !is_user_alive(id)) - if true, player is connected but not alive.
There's no need to check is_user_connected if you're already checking is_user_alive.
is_user_alive itself checks if player is connected.

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);
}
__________________

Last edited by edon1337; 07-17-2018 at 17:57.
edon1337 is offline