Faster? -
Zoopaman - 01.03.2009
Hi everyone!
I was wondering, which method is faster:
A
pawn Код:
if(IsPlayerConnected(playerid) && strcmp(cmd, "/command", true) == 0)
{
//do stuff
}
or B
pawn Код:
if(strcmp(cmd, "/command", true) == 0)
{
if(IsPlayerConnected(playerid))
{
//do stuff
}
}
?
Any hints appreciated
Re: Faster? -
Snyper18 - 01.03.2009
Quote:
Originally Posted by ssǝן‾ʎ
Option C - there is no need for IsPlayerConnected in OnPlayerCommandText as only connected players can type commands.
|
Sorry for offtopic, But that means some GodFather commands saying IsPlayerConnected, Is not needed at all?
Re: Faster? -
1337pr0 - 02.03.2009
Quote:
Originally Posted by Bruzer18
Quote:
Originally Posted by ssǝן‾ʎ
Option C - there is no need for IsPlayerConnected in OnPlayerCommandText as only connected players can type commands.
|
Sorry for offtopic, But that means some GodFather commands saying IsPlayerConnected, Is not needed at all?
|
Probably, depends on the situation.
Re: Faster? -
Daren_Jacobson - 02.03.2009
yes, none of us really know what he was thinking putting all of those in there, and even if it was neccesary, wouldn't a
if(!IsPlayerConnected(playerid)) return 1;
at the top be better?
Re: Faster? -
Damon_Black - 02.03.2009
Well except for the fact that players who haven't even typed a password can do phone calls, advertisements, job commands, and just about every exploit imaginable.
Yeah other than that there is absolutely NO reason at all for IsPlayerConnected. Just put IsPlayerConnected above all the commands except /login and /register and you'll be fine.
Re: Faster? -
ICECOLDKILLAK8 - 02.03.2009
Quote:
Originally Posted by Damon_Black
Well except for the fact that players who haven't even typed a password can do phone calls, advertisements, job commands, and just about every exploit imaginable.
Yeah other than that there is absolutely NO reason at all for IsPlayerConnected. Just put IsPlayerConnected above all the commands except /login and /register and you'll be fine.
|
Do you know what IsPlayerConnected is?, Its nothing to do with login
Re: Faster? -
Damon_Black - 02.03.2009
No I only know what it does and doesn't do. I'm well aware that gPlayerlogged or any other number of handmade definitions will work. But in most gamemodes like GF having that if statement keeps non-logged in players from exploiting your commands.
Re: Faster? -
1337pr0 - 02.03.2009
Quote:
Originally Posted by Damon_Black
No I only know what it does and doesn't do. I'm well aware that gPlayerlogged or any other number of handmade definitions will work. But in most gamemodes like GF having that if statement keeps non-logged in players from exploiting your commands.
|
You don't seem to know what it does at all... If you are trying to stop someone using a command before logging in, IsPlayerConnected won't help - it will return 1 if they are connected to the server, and 0 if they're not. Nothing to do with logging in at all, in ANY game mode.
Re: Faster? -
Damon_Black - 02.03.2009
It's my opinion that the only way to "know" what a function does is to TRY it.
After repeated individuals were pointing out that "IsPlayerIsConnected" was redundant, I removed all instances and tried exploiting those commands.. Which worked. So I placed IsPlayerConnected at the top of OnPlayerCommandText and they were no longer exploitable. This might be isolated to the godfather script but honestly its not worth the amount of hatred that people associate with it. If it works, it works. This is something I troubleshooted after I heard these same assumptions spewed out by other people. If you would like to offer alternatives I'd gladly take them but I am not convinced that you are doing more than repeating what you've heard, compared to say troubleshooting it yourself. Remove IsPlayerConnected from the GF command "/ad" and try to post an ad before logging in. Do it with and without the if statement.
This is what my account of IsPlayerConnected is based on. Not what other people are saying should and shouldn't work.
Re: Faster? -
Nubotron - 02.03.2009
Quote:
Originally Posted by ssǝן‾ʎ
Option C - there is no need for IsPlayerConnected in OnPlayerCommandText as only connected players can type commands.
|
You're partially wrong, if he still use 0.1b, i remember a bug where kicked players can still see chat, gametexts, and use commands. I remember exploiting this bug on PTPM server, after being kicked i used the /me command to tell admins how to fix it :P.
Re: Faster? -
Damon_Black - 02.03.2009
Has it since been fixed? If so I will apologize for my own assumptions that the exploit is still there.
Re: Faster? -
Nubotron - 02.03.2009
Yes, i believe it's fixed since 0.2.