More sscanf help
#1

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..

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;
}
Now, of course this wouldn't work, but logically, this is how it should work in my mind. Any ideas?
Reply


Messages In This Thread
More sscanf help - by Skylar Paul - 15.04.2011, 19:40
Re: More sscanf help - by aircombat - 15.04.2011, 19:59
Re: More sscanf help - by Skylar Paul - 15.04.2011, 20:16
Re: More sscanf help - by Calgon - 15.04.2011, 20:18
Re: More sscanf help - by xir - 15.04.2011, 20:23
Re: More sscanf help - by Skylar Paul - 15.04.2011, 20:52
Re: More sscanf help - by Skylar Paul - 15.04.2011, 22:11
Re: More sscanf help - by Calgon - 16.04.2011, 09:55
Re: More sscanf help - by Finn - 16.04.2011, 10:44
Re: More sscanf help - by playbox12 - 16.04.2011, 11:07

Forum Jump:


Users browsing this thread: 2 Guest(s)