Why "IsPlayerConnected" at a command.
#1

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?
Reply
#2

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.
Reply
#3

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?
Reply
#4

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

Alright, thanks.
Reply
#6

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

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.
Reply
#8

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

Example:

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

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?
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)