
   /* AMX Mod script.
   *
   * (c) Copyright 2003, Dra
   * This file is provided as is (no warranties).
   *
   */
   #include <amxmod>
   #include <amxmisc>
   #define MAX_CLR 8
   #define dfCLR 7
   new ncolors[MAX_CLR][] =
   {"white","red","green","blue","yellow","magenta","cyan","rainbow"}
   new vcolors[MAX_CLR][3] =
   {{255,255,255},{255,0,0},{0,255,0},{0,0,255},
       {255,255,0},{255,0,255},{0,255,255},{0,0,0}}
   new msgchannel
   new logfilename[256]
   public admin_t(id,level,cid) {
       if (!cmd_access(id,level,cid,2))
           return PLUGIN_HANDLED
       if (!changeteam(id,1))
           return PLUGIN_HANDLED
       return PLUGIN_CONTINUE
   }
   public admin_ct(id,level,cid) {
       if (!cmd_access(id,level,cid,2))
           return PLUGIN_HANDLED
       if (!changeteam(id,2))
           return PLUGIN_HANDLED
       return PLUGIN_CONTINUE
   }
   public admin_limitteams(id,level,cid) {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       cvar_cmd(id,"mp_limitteams")
       return PLUGIN_CONTINUE
   }
   public admin_autobalance(id,level,cid) {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       cvar_cmd(id,"mp_autoteambalance")
       return PLUGIN_CONTINUE
   }
   public admin_forcechasecam(id,level,cid) {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       cvar_cmd(id,"mp_forcechasecam")
       return PLUGIN_CONTINUE
   }
   public admin_startmoney(id,level,cid) {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       cvar_cmd(id,"mp_startmoney")
       return PLUGIN_CONTINUE
   }
   public admin_maxrounds(id,level,cid) {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       cvar_cmd(id,"mp_maxrounds")
       return PLUGIN_CONTINUE
   }
   public admin_winlimit(id,level,cid) {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       cvar_cmd(id,"mp_winlimit")
       return PLUGIN_CONTINUE
   }
   public admin_tkpunish(id,level,cid) {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       cvar_cmd(id,"mp_tkpunish")
       return PLUGIN_CONTINUE
   }
   public admin_restartround(id,level,cid) {
       if (!cmd_access(id,level,cid,2))
           return PLUGIN_HANDLED
       cvar_cmd(id,"sv_restartround")
       return PLUGIN_CONTINUE
   }
   public admin_timelimit(id,level,cid) {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       cvar_cmd(id,"mp_timelimit")
       return PLUGIN_CONTINUE
   }
   public admin_fraglimit(id,level,cid) {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       cvar_cmd(id,"mp_fraglimit")
       return PLUGIN_CONTINUE
   }
   public admin_friendlyfire(id,level,cid) {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       cvar_cmd(id,"mp_friendlyfire")
       return PLUGIN_CONTINUE
   }
   public admin_gravity(id,level,cid) {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       cvar_cmd(id,"sv_gravity")
       return PLUGIN_CONTINUE
   }
   public admin_hostname(id,level,cid) {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       cvar_cmd(id,"hostname",1)
       return PLUGIN_CONTINUE
   }
   public admin_banip(id,level,cid) {
       if (!cmd_access(id,level,cid,3))
           return PLUGIN_HANDLED
       new target[32], targetip[16], bantime[8], reason[32]
       new data[64], logdata[128]
       read_argv(1,bantime,7)
       read_argv(2,target,31)
       read_argv(3,reason,31)
       if (!match_num(bantime,0)) {
           console_print(id,"Usage:  amx_banip   <minutes>  <ip  address>
   [reason]")
           return PLUGIN_HANDLED
       }
       new targetid = cmd_target(id,target,9)
       if (!targetid)
           targetid = find_player("d",target)
       if (targetid) {
           new targetname[32]
           get_user_ip(targetid,targetip,15)
           get_user_name(targetid,targetname,31)
           format(data,63,"%s         %s         (%s)        %s",bantime,
   target,targetname,reason)
           format(logdata,127,"^"%s<%d><><%s>^"  (minutes ^"%s^") (reason
   ^"%s^")",
               targetname,get_user_userid(targetid),targetip,bantime,reas
   on)
           client_cmd(targetid,"clear;   echo  *  You  have  been  banned
   because %s; disconnect",reason)
       } else if (match_num(target,1)) {
           copy(targetip,15,target)
           format(data,63,"%s %s %s",bantime,target,reason)
           format(logdata,127,"^"<><><%s>^"   (minutes   ^"%s^")  (reason
   ^"%s^")",
               targetip,bantime,reason)
           console_print(id,"add ip %s to ban list",targetip)
       } else {
           console_print(id,"argument is not match ip address")
           return PLUGIN_HANDLED
       }
       server_cmd("addip %s %s;writeip",bantime,targetip)
       say_command(id,"amx_banip",data,"Ban",logdata)
       return PLUGIN_CONTINUE
   }
   public admin_csay(id,level,cid) {
       if (!cmd_access(id,level,cid,2))
           return PLUGIN_HANDLED
       new color[12], message[128], name[32]
       read_args(message,127)
       remove_quotes(message)
       new length = read_argv(1,color,11)+1
       new found=-1
       for(new i=0;i<MAX_CLR;++i)
           if (equal(color,ncolors[i])) {
               found = i
               break
           }
       if (++msgchannel>6||msgchannel<3)
           msgchannel = 3
       new Float:verpos = 0.24 + float(msgchannel) / 35.0
       get_user_name(id,name,31)
       if (found==-1)
           found=dfCLR
       else
           length = 0
       if (found == 7) {
           new para[168]
           para[0]=msgchannel
           copy(para[1],31,name)
           new paralen = copy(para[33],167,message) + 33
           rainbow_csay(para)
           set_task(1.0,"rainbow_csay",79979+msgchannel,para,paralen,"a",
   9)
       } else {
           set_hudmessage(vcolors[found][0],           vcolors[found][1],
   vcolors[found][2], -1.0, verpos, 0, 0.0, 10.0, 2.0, 3.0, msgchannel)
           show_hudmessage(0,"%s : %s",name,message[length])
       }
       say_command(id,"amx_csay","","Chat",message[length])
       return PLUGIN_CONTINUE
   }
   public admin_ssay(id,level,cid) {
       if (!cmd_access(id,level,cid,2))
           return PLUGIN_HANDLED
       new args[128]
       read_args(args,127)
       client_print(0,print_chat,"[AMX] %s",args)
       return PLUGIN_CONTINUE
   }
   public admin_pass(id,level,cid) {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       if (read_argc() > 1) {
           new argv[32]
           read_argv(1,argv,31)
           set_cvar_string("sv_password",argv)
           say_command(id,"amx_pass","***PROTECTED***","Cmd")
       } else
           repeat_cvar(id,"sv_password")
       return PLUGIN_CONTINUE
   }
   public admin_nopass(id,level,cid) {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       set_cvar_string("sv_password","")
       say_command(id,"amx_nopass","removed          the         server's
   password.","Cmd")
       return PLUGIN_CONTINUE
   }
   changeteam(id,teamid) {
       new data[64], cmdname[2][] = {"amx_t","amx_ct"}
       new len=read_argv(1,data,31)
       new targetid = cmd_target(id,data,9)
       if (targetid) {
           client_cmd(targetid,"clear;chooseteam;menuselect %d;menuselect
   3",teamid)
           new targetname[32]
           get_user_name(targetid,targetname,31)
           format(data[len],63-len," (%s)",targetname)
           say_command(id,cmdname[teamid-1],data,"Cmd")
       }
       return targetid
   }
   cvar_cmd(id,cvarname[],isstrcvar=0) {
       if (read_argc() > 1) {
           new cmd[32], argv[32]
           read_argv(0,cmd,31)
           read_argv(1,argv,31)
           if (isstrcvar)
               set_cvar_string(cvarname,argv)
           else
               set_cvar_num(cvarname,strtonum(argv))
           say_command(id,cmd,argv,"Cmd")
       } else
           repeat_cvar(id,cvarname)
   }
   match_num(str[],isip) {
       new a, b, c
       new len = strlen(str)
       for (new i=0;i<len;++i) {
           if (str[i] == 46) {
               if (++b==a) {
                   c=0
                   continue
               }
           } else if (str[i]<58 && str[i]>47) {
               if (a==b)    a++
               if (a==b+1) {
                   if (!isip)    continue
                   if (c++<3)    continue
               }
           }
           return 0
       }
       if (isip && (a>4 || a<2)) {
           return 0
       }
       if (!isip && a>2) {
           return 0
       }
       if (a && a==b)
           str[len-1]=0
       return a
   }
   public rainbow_csay(para[]) {
       new R, G, B
       R = random(200)
       G = random(200)
       B = random(200)
       if((R+G+B)<150) {
           if (R>G) {
               if (R>B)    R+=100
               else    B+=100
           } else if (G>B)
               G+=100
           else
               B+=100
       }
       set_hudmessage(R,G,  B,  -1.0,  (0.24 + float(para[0]) / 35.0), 0,
   0.1, 1.1, 0.1, 0.2, para[0])
       show_hudmessage(0,"%s : %s",para[1],para[33])
   }
   repeat_cvar(id,cvarname[]) {
       new cvarstr[32]
       get_cvar_string(cvarname,cvarstr,31)
       console_print(id,"Cvar ^"%s^" is ^"%s^"",cvarname,cvarstr)
   }
   say_command(id,cmd[],data[]="",title[]="",logdata[]="") {
       new name[32]
       get_user_name(id,name,31)
       switch(get_cvar_num("amx_show_activity")) {
       case 2:    client_print(0,print_chat,"%s : %s %s",
               name,cmd,data)
       case 1:    client_print(0,print_chat,"%s : %s %s",
               (get_user_flags(id)    &    ADMIN_USER)   ?   "PLAYER"   :
   "ADMIN",cmd,data)
       }
       if (title[0]) {
           new authid[16], a
           if (logdata[0]!=34)
               a=34
           get_user_name(id,name,31)
           get_user_authid(id,authid,15)
           log_to_file(logfilename,"%s: ^"%s<%d><%s><>^" %s %c%s%c",
               title,name,get_user_userid(id),authid,cmd,a,(logdata[0]  ?
   logdata : data),a)
       }
   }
   public plugin_init() {
       register_plugin("Amx AM Like","0.9.1","dra")
       register_concmd("amx_pass","admin_pass",ADMIN_PASSWORD,"<password>
   ")
       register_concmd("amx_nopass","admin_nopass",ADMIN_PASSWORD,"-
   remove server password")
       register_concmd("amx_ssay","admin_ssay",ADMIN_CHAT,"<msg>")
       register_concmd("amx_csay","admin_csay",ADMIN_CHAT,"<msg>")
       register_concmd("amx_banip","admin_banip",ADMIN_BAN,"<minutes> <ip
   address> [reason]")
       register_concmd("amx_hostname","admin_hostname",ADMIN_CVAR,"<hostn
   ame>")
       register_concmd("amx_gravity","admin_gravity",ADMIN_CVAR,"<gravity
   >")
       register_concmd("amx_friendlyfire","admin_friendlyfire",ADMIN_CVAR
   ,"<0 | 1>")
       register_concmd("amx_tkpunish","admin_tkpunish",ADMIN_CVAR,"<0   |
   1>")
       register_concmd("amx_fraglimit","admin_fraglimit",ADMIN_CVAR,"<fra
   glimit>")
       register_concmd("amx_timelimit","admin_timelimit",ADMIN_CVAR,"<min
   utes>")
       register_cvar("amx_show_activity","2")
       new temp[32]
       get_modname(temp,31)
       if (equal(temp,"cstrike")) {
           register_concmd("amx_restartround","admin_restartround",ADMIN_
   CVAR,"<seconds>")
           register_concmd("amx_winlimit","admin_winlimit",ADMIN_CVAR,"<s
   core>")
           register_concmd("amx_maxrounds","admin_maxrounds",ADMIN_CVAR,"
   <rounds>")
           register_concmd("amx_startmoney","admin_startmoney",ADMIN_CVAR
   ,"<money>")
           register_concmd("amx_forcechasecam","admin_forcechasecam",ADMI
   N_CVAR,"<0 | 1 | 2>")
           register_concmd("amx_autobalance","admin_autobalance",ADMIN_CV
   AR,"<0 | 1>")
           register_concmd("amx_limitteams","admin_limitteams",ADMIN_CVAR
   ,"<limitteams>")
           register_concmd("amx_ct","admin_ct",ADMIN_KICK,"<target>")
           register_concmd("amx_t","admin_t",ADMIN_KICK,"<target>")
       }
       get_time("addons/amx/logs/admin%m%d.log",logfilename,255)
       get_mapname(temp,31)
       add(temp,31,".cfg")
       if (file_exists(temp))
           server_cmd("exec %s",temp)
       return PLUGIN_CONTINUE
   }
