IsPlayerConnected usefull?
#1

Hi,

I have some difficulty understanding the importance of IsPlayerConnected(playerid) in a code where playerid is the id of a player wich just interacted with something....

Thank you,
Reply
#2

Quote:
Originally Posted by blinkpnk
Посмотреть сообщение
Hi,

I have some difficulty understanding the importance of IsPlayerConnected(playerid) in a code where playerid is the id of a player wich just interacted with something....

Thank you,
If you use it on that way, it can be pretty useless yeah. But it's important in loops and multi parameter commands.
Reply
#3

multiparameters commands?
Reply
#4

IsPlayerConnected is useful for certain situations. It's not necessary in a script a script however because this:

pawn Код:
if( !IsPlayerConnected( playerid ) )
is basically the same as:

pawn Код:
if( playerid == INVALID_PLAYER_ID )
A example situation involving when checking a player is connected method is the code below (I just wrote it up for this post, this code is not tested)

pawn Код:
CMD:slap( playerid, params[ ] )
{
     static
          s_int
     ;
     if( sscanf( params, "r", s_int ) )
          return false;

     if( s_int == INVALID_PLAYER_ID )
          return false;
 
     static
          Float:s_pos[3]
     ;
     GetPlayerPos( s_int, s_pos[0], s_pos[1], s_pos[2] );
     SetPlayerPos( s_int, s_pos[0], s_pos[1], s_pos[2] + 10 );
     return true;      
}
Reply
#5

OK,

Thanks for your answer
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)