Isplayeroffline
#5

Function:
pawn Код:
bool:IsPlayerNameOffline(name[])
{    
    new pname[MAX_PLAYER_NAME];    
    foreach(new i: Player)
    {                  
        GetPlayerName(i, pname, sizeof(pname));            
        if(strcmp(pname, name, false) == 0) return false;
    }    
    return true;
}
Usage:
pawn Код:
if(IsPlayerNameOffline("SickAttack") == true) // SickAttack is offline.
if(IsPlayerNameOffline("SickAttack") == false) // SickAttack is online.
As I didn't like your function because it's not optimized nor good looking, here you go:
pawn Код:
bool:IsPlayerNameOnline(name[])
{    
    new pname[MAX_PLAYER_NAME];    
    foreach(new i: Player)
    {                  
        GetPlayerName(i, pname, sizeof(pname));            
        if(strcmp(pname, name, false) == 0) return true;
    }    
    return false;
}
Usage:
pawn Код:
if(IsPlayerNameOnline("SickAttack") == false) // SickAttack is offline.
if(IsPlayerNameOnline("SickAttack") == true) // SickAttack is online.
Please note, you'll need the include 'foreach' for this function to work.
Reply


Messages In This Thread
Isplayeroffline - by Bondage - 22.09.2014, 23:15
Re: Isplayeroffline - by DaTa[X] - 22.09.2014, 23:21
Re: Isplayeroffline - by Jaxson - 22.09.2014, 23:21
Re: Isplayeroffline - by WooPz - 22.09.2014, 23:22
Re: Isplayeroffline - by SickAttack - 22.09.2014, 23:28

Forum Jump:


Users browsing this thread: 1 Guest(s)