21.03.2015, 02:02
pawn Код:
IsPlayerOnline(const nick[])
{
if(!nick[0]) return INVALID_PLAYER_ID; // empty nick
static name[MAX_PLAYER_NAME + 1];
for(new i, g = GetMaxPlayers(); i < g; i++)
if(IsPlayerConnected(i))
{
GetPlayerName(i, name, sizeof(name));
if(!strcmp(nick, name))
return i;
}
return INVALID_PLAYER_ID;
}
// in cmd
new ID = IsPlayerOnline(targetname);
if(ID != INVALID_PLAYER_ID) // or if you don't want ID use if(IsPlayerOnline(targetname) != INVALID_PLAYER_ID)
{
// player is online
}
else
{
// player is offline
}