View Single Post
Scherzo
Senior Member
Join Date: Feb 2007
Location: Kwidzyn, Poland
Old 11-21-2008 , 16:38   Re: REQ: Chat Commands Plugin.
Reply With Quote #6

It`s piece of code. To make whole I need more instructions to be sure how it will work (showing messages etc)
Code:
#include <amxmodx>

#define PLUGIN "Chat Commands"
#define VERSION "1.0"
#define AUTHOR "R3X"

new g_cmds[][]=
{
    "kick",
    "ban",
    "banip",
    "score",
    "ff",
    "demo",
    "start",
    "restart",
    "stop"
}
public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);
    register_clcmd("say", "chatFilter",ADMIN_BAN);
}
public chatFilter(id)
{
    new message[128];
    read_argv(1, message, 127);
    for(new i=0;i<sizeof(g_cmds);i++)
    {
        new cmd[33];
        formatex(cmd,32,".%s",g_cmds[i]);
        if(containi(message,cmd)==0)
        {
            callBack(id);
            return PLUGIN_HANDLED;
        }
    }
    return PLUGIN_CONTINUE;
}
getCommandId(cmd[])
{
    for(new i=0;i<sizeof(g_cmds);i++)
    {
        if(equali(cmd, g_cmds[i]))
            return i;
    }
    return -1;
}
public callBack(id)
{
    new message[128], cmd[33],arg[65], arg2[7];
    read_argv (1, message, 128);
    parse(message,cmd,32,arg,64,arg2,6) 
    replace(cmd,32,".","");
    new cID=getCommandId(cmd); 
    switch(cID)
    {
        case 0:
        {
            console_cmd(id,"kick %s", arg);
        }
        case 1:
        {
            new bantime=str_to_num(arg2);
            console_cmd(id,"amx_ban %s %d", arg, bantime);
        }
        case 2:
        {
            new bantime=str_to_num(arg2);
            console_cmd(id,"amx_banip %s %d", arg, bantime);
        }
        case 3:
        {
            //show score
        }
        case 4:
        {
            //set ff
            if(equali(arg,"on"))
            {
                console_cmd(id,"amx_cvar mp_friendlyfire 1");
            }
            else if(equali(arg,"off"))
            {
                console_cmd(id,"amx_cvar mp_friendlyfire 0");
            }
        }
        case 5:
        {
            //record demo
        }
        case 6:
        {
            //start match
        }
        case 7:
        {
            //restart match
        }
        case 8:
        {
            //stop match
        }
    }
    return PLUGIN_HANDLED;
}
For few minutes will be update with seting FF.

Last edited by Scherzo; 11-21-2008 at 16:49.
Scherzo is offline