Quote:
Originally Posted by Jefff
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 }
|
Yes thanks man! this codes helps me the way i needed it.
Tried with sscanf and couldn't make it work. I know its simple yet i cannot understand how to use it right. rep+