[HELP]IsNameOnline - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP]IsNameOnline (
/showthread.php?tid=151418)
[HELP]IsNameOnline -
sushihusi - 30.05.2010
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)
{
...
}
Re: [HELP]IsNameOnline -
Calgon - 30.05.2010
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:
Re: [HELP]IsNameOnline -
sushihusi - 30.05.2010
It doesn't works
Re: [HELP]IsNameOnline -
sushihusi - 30.05.2010
I know the solution!
Код:
new playerid = GetPlayerID("John");
if(playerid > INVALID_PLAYER_ID)
{
...
}
I don't know why but it works.