Optional parameters
#1

What is the default value for optional parameters that are left empty with sscanf?
pawn Код:
CMD:ban(playerid, params[])
{
    if(!IsPlayerAdminEx(playerid, 3)) {
        return SendClientMessage(playerid, COLOR_GREY, "    You are not authorised to use that command!");
    }
   
    new
        target,
        reason[20],
        days;
   
    if(sscanf(params, "usD", target, reason, days)) {
        return SendSyntaxMessage(playerid, "Leave days empty to permaban the player", "/ban [playerid] [reason] [days]");
    }
   
    BanAccount(target, ReturnNameEx(playerid), reason, days == -1 ? -1 : gettime() + (days * 86400));
    return 1;
}
I'm trying to insert -1 in the unbanstamp column if the player left "days" empty.
Reply
#2

Код:
Specifier(s)			Name				Example values
	[i, d			Integer				1, 42, -10
	c			Character			a, o, *
	l			Logical				true, false
	b			Binary				01001, 0b1100
	h, x			Hex				1A, 0x23
	o			Octal				045 12
	n			Number				42, 0b010, 0xAC, 045
	f			Float				0.7, -99.5
	g			IEEE Float			0.7, -99.5, INFINITY, -INFINITY, NAN, NAN_E
	u			User name/id (bots and players)	******, 0
	q			Bot name/id			ShopBot, 27
	r			Player name/id			******, 42
Reply
#3

It's

pawn Код:
z
pawn Код:
sscanf(params, "z", optional)
Reply
#4

I'm asking what the default value of an optional integer is. I already know the sscanf specifiers.
Reply
#5

Perfect! Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)