Small Issue with Kick command.
#1

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.
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;
}
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
pawn Код:
format(str2, sizeof(str2), "|- %s has kicked %s. | Reason: No reason. -|", pName(playerid), pName2(playerid));
I know how to do it using strlen(params) but I am trying to get in the habit of using sscanf.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)