Console command.
#1

Anny idea why doing so doesn't work?

pawn Код:
new
        Player, P2;
    CONSOLE("!setlevel")
    {
        if ( !sscanf( cmd, "dd", Player, P2 ) )
        {
            if ( IsPlayerConnected( Player ) )
            {
                P_DATA[ Player ][ Level ] = P2;
                printf(" >>> You made %s %s of the server! (Level: %d)", Name( Player ), LevelName( P2 ), Player );
            }else PrintError("Player not connected!");
        }else PrintError("Invalid Syntax");
        return 1;
    }
And the define for CONSOLE is
pawn Код:
#define CONSOLE(%0) \
    if ( !strcmp( cmd, (%0), true, .length = strlen( (%0) ) ) )
I mean, what I'm talking about is the sscanf! I can't get it working, even though the code looks alright.

Now, for your information:
I tried even "ud" and was the same result, BUT! When i use "{u}dd" works, any idea why?


For example, using the code above, when i type !setlevel 0 1 it gives me the Invalid Syntax error, when i do in sscanf like "{u}dd" works and gives the right values and all.

Why does it work only when i use quiet sections?


PS: Of course it goes under OnRconCommand
Reply
#2

When you do !setlevel 0 1 then cmd[] = "!setlevel 0 1"

sscanf sees that "!setlevel" is not a number and gives an error. If you use quiet, it will skip this part and go to "0 1"
Reply
#3

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
When you do !setlevel 0 1 then cmd[] = "!setlevel 0 1"

sscanf sees that "!setlevel" is not a number and gives an error. If you use quiet, it will skip this part and go to "0 1"
I see, now that makes perfect sense, forgot that there was no params param in OnRconCommand.

So i could do even if ( sscanf( cmd[ strlen("!setlevel") ], ... )


Right? Of course i would change with the right value instead of using strlen.

Thanks!
Reply
#4

Quote:
Originally Posted by Zh3r0
Посмотреть сообщение
I see, now that makes perfect sense, forgot that there was no params param in OnRconCommand.

So i could do even if ( sscanf( cmd[ strlen("!setlevel") ], ... )


Right? Of course i would change with the right value instead of using strlen.

Thanks!
Yes, this will cut the "!setlevel" part.
Reply
#5

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
Yes, this will cut the "!setlevel" part.
Thanks for the tip, it's easier now without the arpos function and all these functions.

!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)