[HELP]IsNameOnline
#1

Hello!
Can somebody give me a function : IsNameOnline(playername);

I have tried it with getplayerID, but it doesnt works, because if the name isn't online, its gives the money to ID 0.
Here is the code:
Код:
GetPlayerID(playername[])
{
for (new i = 0; i < MAX_PLAYERS; i++)
	{
		if ((IsPlayerConnected(i)) && (strcmp(playername, pName(i), true) == 0))
		{
            return i;
      	}
	}
	return INVALID_PLAYER_ID;
}
And i tried this:
Код:
new playerid = GetPlayerID("John");
	 if(playerid != INVALID_PLAYER_ID)
	 {
	 ...
	 }
Reply
#2

Quote:
Originally Posted by Bart_Simpson
Hello!
Can somebody give me a function : IsNameOnline(playername);

I have tried it with getplayerID, but it doesnt works, because if the name isn't online, its gives the money to ID 0.
Here is the code:
Код:
GetPlayerID(playername[])
{
for (new i = 0; i < MAX_PLAYERS; i++)
	{
		if ((IsPlayerConnected(i)) && (strcmp(playername, pName(i), true) == 0))
		{
            return i;
     	}
	}
	return INVALID_PLAYER_ID;
}
And i tried this:
Код:
new playerid = GetPlayerID("John");
	 if(playerid != INVALID_PLAYER_ID)
	 {
	 ...
	 }
Try this:

pawn Код:
if(playerid != -1)
Reply
#3

It doesn't works
Reply
#4

I know the solution!

Код:
new playerid = GetPlayerID("John");
	 if(playerid > INVALID_PLAYER_ID)
	 {
	 ...
	 }
I don't know why but it works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)