sscanf command problem -
oliverrud - 12.02.2011
Hey, I'm experiencing some problems with my /v [other thing] command using sccanf.
So ofcourse the reason I'm here is that I'm seeking help with it.
Code:
pawn Код:
dcmd_v(playerid, params[])
{
new choice[20];
if(sscanf(params,"s[20]",choice))
{
SendClientMessage(playerid,COLOR_YELLOW,"Usage: /v [action]");
SendClientMessage(playerid,COLOR_YELLOW,"Actions: buy - get");
return 1;
}
else
{
if(equal(params,"buy"))
{
new id;
if(sscanf(params,"s[20]i",choice,id)) return SendClientMessage(playerid,COLOR_YELLOW,"Usage: /v buy [modelid] to get more information");
else
{
//Taken this out for it to look more smooth
}
}
else if(equal(params,"get"))
{
new id;
if(sscanf(params,"s[20]i",choice,id)) return SendClientMessage(playerid,COLOR_YELLOW,"Usage: /v get [1-3]");
else
{
//Taken this out for it to look more smooth
}
}
}
return 1;
}
Okay so what the problem is that, /v works, /v buy shows the return sendclientmessage, but if I do the /v buy and a modelid so for example
/v buy 401
It does nothing.
Exactly the same for /v get
works with /v get shows the return, but if I do /v get 1 it doesn't do the thing it's supposed to do
It can't be the code inside any of them as far as I know, it worked when I only had /v buy but today I started scripting the /v get and that's when it happen that I had to change everything and now I've come across this which I'm unable to fix myself.
Re: sscanf command problem -
Hiddos - 12.02.2011
Try using silent strings. After all, you already know the 'choice':
pawn Код:
if(sscanf(params, "{s[20]}i", id)) return blabla();
Re: sscanf command problem -
oliverrud - 12.02.2011
Didn't do it sadly
But thanks for trying man! Appreciate it.
Re: sscanf command problem -
Gh0sT_ - 13.02.2011
As I know s can't be before i, d, u. so, try
if( sscanf( params, "is[20]", id, choice ) )
Re: sscanf command problem -
oliverrud - 13.02.2011
Nope didn't do it either, tho thanks for trying.
Re: sscanf command problem - Unknown123 - 13.02.2011
Try, (Not sure)
pawn Код:
if(sscanf(params,"dd",choice,id))
Respuesta: sscanf command problem -
Chιrι - 13.02.2011
if(equal(params,"buy"))
else if(equal(params,"get"))
to
if(equal(choice, "buy))
else if(equal(choice,"get"))
?
Re: sscanf command problem -
Hal - 13.02.2011
Quote:
Originally Posted by Gh0sT_
As I know s can't be before i, d, u. so, try
if( sscanf( params, "is[20]", id, choice ) )
|
There is nothing anywhere that says that.
Re: Respuesta: sscanf command problem -
oliverrud - 13.02.2011
Quote:
Originally Posted by Chιrι
if(equal(params,"buy"))
else if(equal(params,"get"))
to
if(equal(choice, "buy))
else if(equal(choice,"get"))
?
|
Already attempted that myself
Re: sscanf command problem -
JaTochNietDan - 13.02.2011
Well think about what you're comparing for a second, look at this:
So you type "/v buy", then obviously params and buy match, so that if statement returns true, then it continues down into your sscanf check and sscanf says there's no second integer parameter, and it returns the message. So then you type "/v buy 50", then it goes to compare params and "buy" again, and it's no longer going to return true, because now params contains "buy 50".
So what can you do? Well actually you pretty much already have it solved, you just need to change one little thing:
Hope that explains it and helps.