15.04.2011, 19:40
In my quest to fully learn sscanf, I have ran across alot of problems, and questions; This one has always stumped me. How would I go about adding an optional parameter? According to the official sscanf release topic, "i" is an optional integer, and "S" is an optional string - How would I go about making it optional? Such as..
Now, of course this wouldn't work, but logically, this is how it should work in my mind. Any ideas?
pawn Код:
COMMAND:muteplayer(playerid, params[])
{
new MuteReason[128], String[128], Player;
if(sscanf(params, "uS[128]", Player, MuteReason)) { //"S" is the optional string parameter according to ******' topic.
SendClientMessage(playerid, c_white, "[USAGE] /MutePlayer [Player ID] [Mute Reason (optional)]");
return 1;
}
SetPVarInt(Player, "Muted", 1);
if(!MuteReason)) {
format(String, sizeof(String), "You have been muted by Administrator %s, Reason: No Reason Specified.", pName(playerid));
return 1;
}
else {
format(String, sizeof(String), "You have been muted by Administrator %s, Reason: \"%s\"", pName(playerid), MuteReason);
}
SendClientMessage(playerid, c_white, String);
return 1;
}