SA-MP Forums Archive
Why "IsPlayerConnected" at a command. - 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: Why "IsPlayerConnected" at a command. (/showthread.php?tid=228300)



Why "IsPlayerConnected" at a command. - Biesmen - 19.02.2011

This is probably a retarded question, but I've seen this at many scripts.

Many scripts are checking if the player is online when they use a command.
Why the hell would you do that? A player can only use a command if he's connected!

Is this some pure "dumbness" in those scripts, or is it me?


Re: Why "IsPlayerConnected" at a command. - Jochemd - 19.02.2011

It's from the old SAMP 0.1 where you could still use commands after being banned or kicked. Thats why check if they're connected.


Re: Why "IsPlayerConnected" at a command. - Biesmen - 19.02.2011

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
It's from the old SAMP 0.1 where you could still use commands after being banned or kicked.
Yes, I know that. But those scripts are since SAMP 0.3. Why are they still using that stuff?


Re: Why "IsPlayerConnected" at a command. - Jochemd - 19.02.2011

I think they just do automatically... Scripting since 0.1. I also think it's dumb to check for 'playerid'.


Re: Why "IsPlayerConnected" at a command. - Biesmen - 19.02.2011

Alright, thanks.


Re: Why "IsPlayerConnected" at a command. - Mean - 19.02.2011

Maybe they just do it to get alot of lines, so people think the script is "better".


Re: Why "IsPlayerConnected" at a command. - Ash. - 19.02.2011

Well, in my opinion, i only use IsPlayerConnected in Loops, or in "OnFilterScriptInit" - otherwise, i dont. Many functions already check to see whether the player is connected before the command is executed.


Re: Why "IsPlayerConnected" at a command. - Serbish - 19.02.2011

' IsPlayerConnected(playerid); ' function is useful at some points.

Example:

pawn Код:
/givemoney [id] [amount]
If player ' id ' is not connected it gives a message back.


Re: Why "IsPlayerConnected" at a command. - Mean - 19.02.2011

Yes, but it's useless in cmds like this:
pawn Код:
CMD:teleport( playerid, params[ ] )
{
    if( IsPlayerConnected( playerid ) )
    {
        SetPlayerPos( playerid, 0.0, 0.0, 0.0 );
    }
    return 1;
}
Isn't it?


Re: Why "IsPlayerConnected" at a command. - Serbish - 19.02.2011

Quote:
Originally Posted by Mean
Посмотреть сообщение
Yes, but it's useless in cmds like this:
pawn Код:
CMD:teleport( playerid, params[ ] )
{
    if( IsPlayerConnected( playerid ) )
    {
        SetPlayerPos( playerid, 0.0, 0.0, 0.0 );
    }
    return 1;
}
Isn't it?
Ofc, it's just useful if it has something to do with another player and you need check if that player is connected.
But for a command where only you are involved it's not needed.