Help with sscanf2 - 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)
+--- Thread: Help with sscanf2 (
/showthread.php?tid=383524)
Help with sscanf2 -
tMike - 07.10.2012
Hey dear,
i have still a little question by using sscanf2:
How can I do it like this?
pawn Код:
if(strcmp(string,"/shop",true) == 0)
{
new x_nr[64];
x_nr = strtok(cmdtext, idx);
if(!strlen(x_nr)) return SendClientMessage(playerid, 0xAA3333AA,"ERROR: /shop [buy/sell/own]");
if(strcmp(x_nr,"buy",true) == 0)
{
//some stuff here
}
else if(strcmp(x_nr,"sell",true) == 0)
{
//some stuff here
}
else if(strcmp(x_nr,"own",true) == 0)
{
//some stuff here
}
return 1;
}
I try it like this:
pawn Код:
COMMAND:shop(playerid, params[])
{
new act[7];
if (!sscanf(params, "s", act))
{
if(!sscanf("buy","s",act))
{
//some stuff here
}
else if(!sscanf("sell","s",act))
{
//some stuff here
}
else if(!sscanf("own","s",act))
{
//some stuff here
}
} else SendClientMessage(playerid, 0xAA3333AA,"ERROR: /shop [buy/sell/own]");
return 1;
}
But it didnt work, if I type in /shop sell (same with /show own), it shows me the code from /shop buy.
How can I do such a thing with sscanf? Sorry, im really new to sscanf, I allways used strcmp.
Thanks for help.
Re: Help with sscanf2 -
ReneG - 07.10.2012
You don't need sscanf for one parameter. isnull() comes with zcmd.
PHP код:
CMD:command(playerid, params[])
{
if(isnull(params)) {
return SendClientMessage(playerid, -1, "USAGE: /command [name]");
}
else if(!strcmp(params, "car", true)) {
// player typed car after /command
}
else if(!strcmp(params, "apple", true)) {
// player typed apple after /command
}
return 1;
}
AW: Help with sscanf2 -
tMike - 07.10.2012
Thanks a lot.
test