optional parameters with sscanf
#3

Quote:
Originally Posted by rappy93
Посмотреть сообщение
pawn Код:
if(sscanf(params,"d", playerid)) return SendClientMessage(playerid, "/kick [target id]");
Think this might do it.
This can help.
If you want to add a reason to it use this:

pawn Код:
if(sscanf(params, "us[128]", tID, reason)) return SendClientMessage(playerid, /*COLOR HERE*/, "* [USAGE]: /kick [playerid/PartOfName] [Reason]");
I replaced the "d" with "u" so you can type a part of the players name or his ID.
"s" stands for string, that means that it's a message, in this case: your reason.
"[128]", behind the "s" is the maximum length your reason can have.

If you want to make your reason optional, use this:

pawn Код:
if(sscanf(params, "uS(No Reason)[128]", tID, reason)) return SendClientMessage(playerid, /*COLOR HERE*/, "* [USAGE]: /kick [playerid/PartOfName] [Reason]");
Make sure you have a local variable. Example:
pawn Код:
new reason[128];
Edit:
I forgot to mention that "tID" is the targetid, you have to make a local variable for that one too.
pawn Код:
new tID;
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)