Optional parameters - 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 parameters (
/showthread.php?tid=389827)
Optional parameters -
ReneG - 03.11.2012
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.
Re: Optional parameters -
ThePhenix - 03.11.2012
Код:
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
AW: Optional parameters -
Skimmer - 03.11.2012
It's
pawn Код:
sscanf(params, "z", optional)
Re: Optional parameters -
ReneG - 03.11.2012
I'm asking what the default value of an optional integer is. I already know the sscanf specifiers.
Re: Optional parameters -
ReneG - 03.11.2012
Perfect! Thank you.