optional parameters with sscanf
#7

Use optional string as Bible showed you. You also don't need to check anything because "reason" array stores the text whether the input was given or not.
pawn Код:
CMD:kick(playerid, params[])
{
    new targetid, reason[64];
    if (sscanf(params, "rS(No reason specified)[64]", targetid, reason)) return SendClientMessage(playerid, COLOR_HERE, "Usage: /kick [id] [reason]");
    //rest of code here
    new msg[144];
    format(msg, sizeof (msg), "%s has been kicked <> Reason: %s", ..., reason);
    // ... is the argument for the name, modify it accoding to the code you have..
    SendClientMessageToAll(COLOR_HERE, msg);
    return 1;
}
EDIT: Didn't refresh the page.

--

Yes, the text should be inside parentheses and it doesn't matter about the letter case (lower/upper).

Documentation for optional strings: https://github.com/Y-Less/sscanf/wik...tional-strings
Reply


Messages In This Thread
optional parameters with sscanf - by jamjamnewbie - 22.05.2014, 13:12
Re: optional parameters with sscanf - by rappy93 - 22.05.2014, 13:14
Re: optional parameters with sscanf - by AndySedeyn - 22.05.2014, 13:21
Re: optional parameters with sscanf - by jamjamnewbie - 22.05.2014, 13:32
Re: optional parameters with sscanf - by AndySedeyn - 22.05.2014, 13:36
Re: optional parameters with sscanf - by jamjamnewbie - 22.05.2014, 13:39
Re: optional parameters with sscanf - by Konstantinos - 22.05.2014, 13:42
Re: optional parameters with sscanf - by AndySedeyn - 22.05.2014, 13:43

Forum Jump:


Users browsing this thread: 1 Guest(s)