Creating a Command reason
#10

Using strtok to check parameters is an impractical way of making commands.

Here you can see a ban command be made in 20 lines.
pawn Код:
CMD:ban(playerid,params[])
{
    new string[128],
        reason[50],
        target;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You are not allowed to use this command.");
    if(sscanf(params,"us[50]",target,reason)) return SendClientMessage(playerid, -1, "USAGE: /ban [playerid] [reason]");
    else
    {
        new
            name[24],
            targetname[24];
        GetPlayerName(playerid,name,sizeof(name));
        GetPlayerName(target,targetname,sizeof(targetname));
        format(string,sizeof(string),"Administrator %s has banned %s. Reason: %s",name,targetname,reason);
        SendClientMessageToAll(-1, string);
        Ban(target);
    }
    return 1;
}
Reply


Messages In This Thread
Creating a Command reason - by stormchaser206 - 06.04.2012, 21:58
Re: Creating a Command reason - by ReneG - 06.04.2012, 22:27
Respuesta: Creating a Command reason - by Chris1337 - 06.04.2012, 22:33
Respuesta: Creating a Command reason - by TiNcH010 - 06.04.2012, 22:56
Respuesta: Creating a Command reason - by Chris1337 - 06.04.2012, 23:48
Respuesta: Creating a Command reason - by TiNcH010 - 06.04.2012, 23:52
Re: Creating a Command reason - by [HiC]TheKiller - 07.04.2012, 00:18
Re: Creating a Command reason - by stormchaser206 - 08.04.2012, 21:13
Re: Creating a Command reason - by kikito - 08.04.2012, 21:16
Re: Creating a Command reason - by ReneG - 08.04.2012, 21:40

Forum Jump:


Users browsing this thread: 1 Guest(s)