Optional Integers? SSCANF.
#1

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)
Reply
#2

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.
Reply
#3

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.
Reply
#4

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.
Reply
#5

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)