Posts: 87
Threads: 35
Joined: Oct 2013
Reputation:
0
I am trying to create a command like this:
/give currentgun
/give gun <gunid>
but everything I've tried till now just didn't work, how can I simply make optional parameters?
Posts: 1,506
Threads: 13
Joined: Jun 2015
PHP код:
if(sscanf(params, "s[buffer size]S(default value)[buffer size]", type, optional))
Example:
PHP код:
flags:kick(CMD_ADMIN);
CMD:kick(playerid, params[])
{
if(pInfo[playerid][AdminLvl] < 1) return 0;
new targetid, str[144], reason[72];
if(sscanf(params, "uS(No reason given)[72]", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /kick [ID] [REASON]"), 0;
if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: "COL_GREY"Player is not connected."), 0;
if(pInfo[targetid][AdminLvl] > pInfo[playerid][AdminLvl]) return SendClientMessage(playerid, COLOR_RED, "ERROR: "COL_GREY"Player's admin level is higher or same as yours."), 0;
format(str, sizeof str, "%s %s has kicked %s for reason: %s.", gStaff[pInfo[playerid][AdminLvl]], pName[playerid], pName[targetid], reason);
SendClientMessageToAll(COLOR_PINK, str);
KickEx(targetid);
return 1;
}
Posts: 87
Threads: 35
Joined: Oct 2013
Reputation:
0
I am either blind or the wiki page really does miss that information.
Thanks for the help!