22.09.2014, 23:28
Function:
Usage:
As I didn't like your function because it's not optimized nor good looking, here you go:
Usage:
Please note, you'll need the include 'foreach' for this function to work.
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;
}
pawn Код:
if(IsPlayerNameOffline("SickAttack") == true) // SickAttack is offline.
if(IsPlayerNameOffline("SickAttack") == false) // SickAttack is online.
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;
}
pawn Код:
if(IsPlayerNameOnline("SickAttack") == false) // SickAttack is offline.
if(IsPlayerNameOnline("SickAttack") == true) // SickAttack is online.