Console 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: Console command. (
/showthread.php?tid=252895)
Console command. -
Zh3r0 - 03.05.2011
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
Re: Console command. -
MadeMan - 03.05.2011
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"
Re: Console command. -
Zh3r0 - 03.05.2011
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!
Re: Console command. -
MadeMan - 03.05.2011
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.
Re: Console command. -
Zh3r0 - 03.05.2011
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.
!