Help with 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with SSCANF (
/showthread.php?tid=181257)
Help with SSCANF -
The_Moddler - 04.10.2010
I'm making a command with sscanf,
pawn Код:
if(sscanf(params, "us[8]d", id, objetos, cantidad)) return SendClientMessage(playerid, COLOR_WHITE, "USO: /dar [id/ParteNombre] [Arma-Bombas-Chaleco-Dinero] [cantidad]");
But,
cantidad will only be used if the player tipes
/dar dinero(/give money howmuch) or
/dar bombas(/give bombs howmany), but if player tipes
/dar arma(/give weapon),
cantidad will not be used, and sscanf sends me how to use the command
pawn Код:
return SendClientMessage(playerid, COLOR_WHITE, "USO: /dar [id/ParteNombre] [Arma-Bombas-Chaleco-Dinero] [cantidad]");
Thanks
Re: Help with SSCANF -
samgreen - 04.10.2010
Quote:
Originally Posted by The_Moddler
I'm making a command with sscanf,
pawn Код:
if(sscanf(params, "us[8]d", id, objetos, cantidad)) return SendClientMessage(playerid, COLOR_WHITE, "USO: /dar [id/ParteNombre] [Arma-Bombas-Chaleco-Dinero] [cantidad]");
But, cantidad will only be used if the player tipes /dar dinero(/give money howmuch) or /dar bombas(/give bombs howmany), but if player tipes /dar arma(/give weapon), cantidad will not be used, and sscanf sends me how to use the command
pawn Код:
return SendClientMessage(playerid, COLOR_WHITE, "USO: /dar [id/ParteNombre] [Arma-Bombas-Chaleco-Dinero] [cantidad]");
Thanks
|
Okay so if I understand correctly the third parameter (cantidad) is optional. Sscanf supports optional parameters by capitalizing the format string, ie "us[8]D". This means that the last parameter can be left out, and sscanf will not return an error.
Re: Help with SSCANF -
smeti - 04.10.2010
Quote:
Originally Posted by samgreen
Okay so if I understand correctly the third parameter (cantidad) is optional. Sscanf supports optional parameters by capitalizing the format string, ie "us[8]D". This means that the last parameter can be left out, and sscanf will not return an error.
|
Set optional parameter () and sscanf will not return an error. (Use sscanf plugin)
Re: Help with SSCANF -
The_Moddler - 04.10.2010
Thanks guys