28.07.2010, 20:18
Hi, I'm still trying to learn 'sscanf' and I'm not to good at it, I am trying to make a kick command with a optional params for reasons.
I'm using zcmd.
I get no errors when compiling, but I wanted to make it so where if the player doesn't want to include a reason it would say
I know how to do it using strlen(params) but I am trying to get in the habit of using sscanf.
I'm using zcmd.
pawn Код:
CMD:kick(playerid, params[])
{
new reason[128], str[128], str2[128], player1;
if(PlayerInfo[playerid][LoggedIn] == 1)
{
if(PlayerInfo[playerid][Level] >= 1)
{
if(sscanf(params, "us", player1, reason))
{
return SendClientMessage(playerid, YELLOW, "USAGE: /kick (Name/ID) (Reason)");
}
format(str, sizeof(str), "|- %s has kicked %s. | Reason: %s -|", pName(playerid), pName2(playerid), reason);
SendClientMessageToAll(BLUE, str);
Kick(player1);
}
else return SendClientMessage(playerid, RED, "ERROR: You are not a level 1 admin!");
}
else return SendClientMessage(playerid, RED, "ERROR: You need to be logged in to use these commands!");
return 1;
}
pawn Код:
format(str2, sizeof(str2), "|- %s has kicked %s. | Reason: No reason. -|", pName(playerid), pName2(playerid));