[Tutorial] Using zcmd && sscanf
#3

Quote:
Originally Posted by Kaylux
Посмотреть сообщение
pawn Код:
COMMAND:kick(playerid, params[])
{
    new giveplayerid, reason[24], string[125], name[24];
    if(IsPlayerAdmin(playerid))
    {
        if(sscanf(params, "is", giveplayerid, reason)) return SendClientMessage(playerid,WHITE,"[ERROR]Usage: /kick [playerid] [reason]");
        else if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid,WHITE,"[ERROR] Player Is Not Connected");
        else
        {
            GetPlayerName(giveplayerid, name, sizeof(name));
            format(string, sizeof(string), "<< ADM KICK >> Admin %s kicked %s(%d) | Reason: %s", name, GetPlayerNameEx(giveplayerid), giveplayerid, reason);
            SendClientMessageToAll(YELLOW, string);
            Kick(giveplayerid);

        }
    }
    else return SendClientMessage(playerid, WHITE, "SERVER: Unknown Command");
    return 1;
}
If you are using newest version of 'sscanf' here, you need to add string lenght in sscanf parameters.

pawn Код:
if(sscanf(params, "is[24]", giveplayerid, reason)) return SendClientMessage(playerid,WHITE,"[ERROR]Usage: /kick [playerid] [reason]");
If you don't do this, it will print warning to server console.

Even if this isn't much of a problem, you could still edit your post and hopefully make it "better".
Reply


Messages In This Thread
Using zcmd && sscanf - by Kaylux - 03.01.2011, 11:55
Re: Using zcmd && sscanf - by Balcan Fox - 03.01.2011, 13:30
Re: Using zcmd && sscanf - by Doom8890 - 04.01.2011, 00:50
Re: Using zcmd && sscanf - by Kaylux - 04.01.2011, 01:37
Re: Using zcmd && sscanf - by [03]Garsino - 04.01.2011, 02:54
Re: Using zcmd && sscanf - by DarrenReeder - 04.01.2011, 22:22

Forum Jump:


Users browsing this thread: 1 Guest(s)