IsPlayerConnected question
#4

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+
Reply


Messages In This Thread
IsPlayerConnected question - by maximthepain - 21.03.2015, 01:16
Re: IsPlayerConnected question - by Jefff - 21.03.2015, 02:02
AW: IsPlayerConnected question - by Nero_3D - 21.03.2015, 02:28
Re: IsPlayerConnected question - by maximthepain - 21.03.2015, 10:48
Re: IsPlayerConnected question - by Pottus - 21.03.2015, 11:07

Forum Jump:


Users browsing this thread: 1 Guest(s)