
   /* AMXMOD script.
   *
   *  (c) Copyright 2000-2002, Made by Rich - This file is provided as is
   (no warranties).
   *
   * CHEATING DEATH MEDIATOR EXTENDED V1.0
   *
   */
   #include <amxmod>
   #include <amxmisc>
   new   klimit,  kdratio,  no_cd[33],  no_cd_wonid[33],  filepath[33]  =
   "/addons/amx/mediator.ini"
   public plugin_init()
   {
     register_plugin("C-D Mediator Extended", "1.0", "Rich")
     register_cvar("amx_cd_ratio", "2")
     register_cvar("amx_cd_limit", "14")
     register_concmd("amx_cd_add","add_player",ADMIN_KICK,"< Part of Name
   >")
     register_concmd("amx_cd_clear","clear_player",ADMIN_BAN,"-    Remove
   all stored WonID")
     register_srvcmd("amx_mediator_cd", "cd_valid")
     register_srvcmd("amx_mediator_nocd", "cd_invalid")
     set_cvar_string("cdvalidatecmd","amx_mediator_cd %d")
     set_cvar_string("cdnovalidatecmd","amx_mediator_nocd %d")
     set_cvar_string("cdoldvalidatecmd","amx_mediator_nocd %d")
     register_cvar("amx_cd_mediator", "1.0",FCVAR_SERVER)
     register_logevent("check_players", 2, "1=Round_Start")
     load_file()
   }
   public client_connect(id)
   {
     no_cd[id] = false
   }
   public client_disconnect(id)
   {
     no_cd[id] = false
   }
   public cd_valid()
   {
     new playerids[8]
     read_argv(1, playerids, 7)
     new playeridn = find_player("k", strtonum(playerids))
     no_cd[playeridn] = false
     new name[9]
     get_user_name(playeridn,name,8)
     if ( equali(name,"[No C-D]") || equali(name,"[Old C-D") )
     {
       kick_warn(playeridn)
     }
     return PLUGIN_CONTINUE
   }
   public cd_invalid()
   {
     new playerids[8]
     read_argv(1, playerids, 7)
     new playeridn = find_player("k", strtonum(playerids))
     no_cd[playeridn] = true
     new wonid = get_user_wonid(playeridn)
     for(new a = 0; a <= 32; ++a)
     {
       if (wonid == no_cd_wonid[a])
       {
         kick_warn(playeridn)
       }
     }
     if (get_user_time(playeridn) > 120)
     {
       new name[9]
       get_user_name(playeridn,name,8)
       if ( !(equali(name,"[No C-D]")) || !(equali(name,"[Old C-D")) )
       {
         kick_warn(playeridn)
       }
     }
     return PLUGIN_CONTINUE
   }
   public check_players()
   {
     klimit = get_cvar_num("amx_cd_limit")
     kdratio = get_cvar_num("amx_cd_ratio")
     for(new a = 1; a <= get_maxplayers(); ++a)
     {
       if (no_cd[a])
       {
         text_warn(a)
         if (get_user_frags(a) >= klimit)
         {
           if  (float(get_user_frags(a))  /  float(get_user_deaths(a)) >=
   float(kdratio))
           {
             save_file(a)
             kick_warn(a)
           }
         }
       }
     }
   }
   public text_warn(id)
   {
     client_print(id,print_chat,"YOU ARE NOT RUNNING C-D ANTI CHEAT")
     client_print(id,print_chat," ")
     client_print(id,print_chat,"DOWNLOAD IT FROM WWW.CHEATINGDEATH.NET")
   }
   public kick_warn(id)
   {
     client_cmd(id,"console 1")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"==============================================================^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo  ^"    THE  SERVER  NOW  REQUIRES YOU TO RUN C-D
   WHILE PLAYING      ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo  ^"    C-D  BLOCKS CHEATS SO YOU CAN SEE PEOPLES
   *REAL* SKILL     ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo  ^"           DOWNLOAD  IT  NOW  AND  SHOW  YOUR
   CLEAN                ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"           WEBSITE:      WWW.CHEATINGDEATH.NET                ^"")
     client_cmd(id,"echo
   ^"                                                              ^"")
     client_cmd(id,"echo
   ^"==============================================================^"")
     new ids[1]
     ids[0] = id
     set_task(1.0,"kick_player",123,ids,1)
   }
   public kick_player(ids[])
   {
   //client_print(0,print_chat,"Player   %i   Kicked   For   Not   Having
   C-D",ids[0])
     server_cmd("kick #%i",get_user_userid(ids[0]))
   }
   public save_file(id)
   {
     for(new a = 0; a <= 31; ++a)
     {
       no_cd_wonid[32 - a] = no_cd_wonid[31 - a]
     }
     no_cd_wonid[0] = get_user_wonid(id)
     if (file_exists(filepath))
     {
       delete_file(filepath)
     }
     new text[10]
     for(new a = 0; a <= 32; ++a)
     {
       format(text, 9, "%i", no_cd_wonid[a])
       write_file(filepath, text)
     }
   }
   public load_file()
   {
     new text[10], textlen
     if (file_exists(filepath))
     {
       for(new a = 0; a <= 32; ++a)
       {
         read_file(filepath, a, text, 255, textlen)
         no_cd_wonid[a] = strtonum(text)
       }
     }
   }
   public add_player(id,level,cid)
   {
     if (!cmd_access(id,level,cid,2))
     {
       return PLUGIN_CONTINUE
     }
     new arg[32]
     read_argv(1,arg,31)
     new playeridn = cmd_target(id,arg,1)
     if (!playeridn)
     {
       return PLUGIN_HANDLED
     }
     for(new a = 0; a <= 32; ++a)
     {
       if ( no_cd_wonid[a] == get_user_wonid(playeridn) )
       {
         console_print(id,"Player is already in the list.")
         return PLUGIN_HANDLED
       }
     }
     save_file(playeridn)
     if (no_cd[playeridn])
     {
       kick_warn(playeridn)
     }
     console_print(id,"Player now required to use C-D.")
     return PLUGIN_HANDLED
   }
   public clear_player(id,level,cid)
   {
     if (!cmd_access(id,level,cid,0))
     {
       return PLUGIN_CONTINUE
     }
     if (file_exists(filepath))
     {
       delete_file(filepath)
     }
     for(new a = 0; a <= 32; ++a)
     {
       no_cd_wonid[a] = 0
     }
     console_print(id,"All stored WonID removed.")
     return PLUGIN_HANDLED
   }
