multiple parameters using sscanf - 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: multiple parameters using sscanf (
/showthread.php?tid=306329)
multiple parameters using sscanf -
fordawinzz - 26.12.2011
i'm just wondering, how to do this? I mean a command like: /trunk [store, get, show] [item] [name, amount]
Re: multiple parameters using sscanf -
Ash. - 26.12.2011
pawn Code:
new
action[6], // store is 5 characters long (and the longest word), add another to make it big enough.
item[64], //Assuming that the item parameter is going to be a string/name.
amount //Assuming a number/integer.
;
//Template: sscanf(input_string, format/specifiers, output_variables in order of appearence in specifiers);
sscanf(params, "s[6]s[64]i", action, item, amount);
Hopefully this explains it well enough.
Re: multiple parameters using sscanf -
blewert - 26.12.2011
Use what funky posted. You'd then check inside the command on what action they specified (to store, get or show) with a simple if/else if expression:
pawn Code:
if( !strcmp(action, "store") )
{
// .. They want to store
}
else if( !strcmp(action, "get") )
{
// .. They want to get
}
else if( !strcmp( action, "show") )
{
// .. They want to show
}
else
{
// .. Unknown action
}
Re: multiple parameters using sscanf -
fordawinzz - 26.12.2011
yeah, I did that but what about this: /trunk store weapon desert? the amount should be integer OR string, that's what I can't do
blewert: I did that before to make this topic..
nvm.. strval did it
Re: multiple parameters using sscanf -
zT KiNgKoNg - 28.07.2013
Here, Next time use ****** to search.
pawn Code:
CMD:take(playerid, params[])
{
if(!strlen(params))
{
SendClientMessage(playerid, -1,"Syntax: /take [option]");
SendClientMessage(playerid, -1,"Drugs - Crack - Pot - Money");
}
else if(strcmp(params,"drugs",true) == 0)
{
}
else if(strcmp(params,"crack",true) == 0)
{
}
else if(strcmp(params,"pot",true) == 0)
{
}
else if(strcmp(params,"money",true) == 0)
{
}
return 1;
}