Faster?
#1

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

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

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

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

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

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

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

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

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

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.

Reply
#11

Has it since been fixed? If so I will apologize for my own assumptions that the exploit is still there.
Reply
#12

Yes, i believe it's fixed since 0.2.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)