Checking is player online. - 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)
+--- Thread: Checking is player online. (
/showthread.php?tid=307142)
Checking is player online. -
BaubaS - 29.12.2011
Im having a problem with checking is player online. So, I have an optional parameter (
R). If player didnt used the param, the value will be -1. So, I want to do this: if player is offline, it would return that player is offline. BUT, if player didnt used the param (
R) it would continue the command. Now it always return that player is offline, even I didnt used the param
pawn Код:
new i;
if (sscanf(params, "R(-1)", i))
{
return SendClientMessage(playerid, 0xFF0000FF, "Komandos naudojimas: {FFFF00}/(lok)uoti [vardas]");
}
if (i == playerid || i == INVALID_PLAYER_ID && i != -1)
{
return SendClientMessage(playerid, 0xFF0000FF, "Ћaidėjas yra neprisijungęs!");
}
Re: Checking is player online. -
DonWade - 29.12.2011
new Spawned[MAX_PLAYERS];
set on player spawn
Spawned[playerid] =1;
now in command put
if(Spawned[playerid] != 1)
{
SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command.");
return 1;
}
Re: Checking is player online. -
Seven_of_Nine - 29.12.2011
Why don't you do it with IsPlayerConnected(playerid)?
Re: Checking is player online. -
BaubaS - 29.12.2011
DonWade - you dont understand, what do I need actually.
seven_of_nine - using INVALID_PLAYER_ID is faster AFAIK, because its not a function, its a define.. and IsPlayerConnected is a function.
any ideas to the topic?
Re: Checking is player online. -
THE_KNOWN - 29.12.2011
pawn Код:
if (i == playerid && i == INVALID_PLAYER_ID && i != -1) // || to &&