SA-MP Forums Archive
Optional Integers? 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: Optional Integers? SSCANF. (/showthread.php?tid=313208)



Optional Integers? SSCANF. - Dokins - 24.01.2012

pawn Код:
if(sscanf(params, "uDDs[128]", giveplayerid,hours,days, reason)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /tban [player id] [hours] [days] [reason]");
It returns the message although I stated the 2 are optional (hours and days)


Re: Optional Integers? SSCANF. - 2KY - 24.01.2012

pawn Код:
if(sscanf(params, "uD(0)D(0)s[128]", giveplayerid,hours,days, reason)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /tban [player id] [hours] [days] [reason]");
This will automatically return 0 if none are entered.


Re: Optional Integers? SSCANF. - Dokins - 24.01.2012

Yes, I've added the D(0)'s and it still returns the client message. I'd like to only to be able to select one parameter without it returning the message.


Re: Optional Integers? SSCANF. - 2KY - 24.01.2012

You will probably have to reorder your command syntax in order for this to work.. but,

As far as I know, you'd have to do a separate thing like:

pawn Код:
if(sscanf(params, "uD(0)D(0)s[128]", user, date1, date2, string))
{
if(isnull(date1) { date1 = ..; }
else if(isnull(date2) { date2 = ..; }
}
and go on like that, although, I definately could be wrong. Just throwing ideas out there.


Re: Optional Integers? SSCANF. - 2KY - 24.01.2012

Quote:
Originally Posted by ******
Посмотреть сообщение
You can't have optional parameters that aren't the last ones with the default separator.
Ah, I knew it. ******, could you show me how to do it with a custom separator by any chance?