
   /* AMX Mod script.
   *
   * (c) Copyright 2002-2003, OLO
   * This file is provided as is (no warranties).
   *
   * This is an emulation of WWCL. Install WWCL
   * as always but remove dll link entry form
   * metamod plugins.ini config file, because
   * this script does its job.
   * WWCL can be found @ http://wwcl.net/
   */
   #include <amxmod>
   #define MAXCVARS 64
   new g_checkCvar[MAXCVARS][24]
   new g_checkValue[MAXCVARS][8]
   new g_checkNum
   #define MAXMSG 24
   new g_consoleMsg[MAXMSG][64]
   new g_consoleNum
   new g_ackCode[33]
   new g_clientPos[33]
   /* Initialization point */
   public plugin_init()
   {
     register_plugin("WWCL Emulator","0.1","default")

   //  register_cvar(  "wwclconfig_cfgversion","none")  // registered but
   not used in WWCL ?!
     register_cvar(                        "wwclconfig_version","unknown"
   ,FCVAR_SERVER|FCVAR_UNLOGGED|FCVAR_SPONLY)

     register_cvar("wwclconfig","1")
     register_cvar("wwclconfig_delay","10")

     register_cvar("wwclconfig_break","7200")    /*    not    worth    of
   implmenting.
     There  is  no  harm  for clients with enforce. It takes less than 30
   sec.
     and enforcing shouldn't cause any additional latency. */

     register_cvar("wwclconfig_frequency","0.25")

     register_cvar("wwclconfig_loadcfg","1")
     register_cvar("wwclconfig_logfile","wwclconfig.log")

     register_cvar("wwclconfig_action","disconnect")
     register_cvar("wwclconfig_success","say ^"WWCL: Validated^"")

     register_srvcmd("wwclconfig_check","cmdCheck")
     register_srvcmd("wwclconfig_msg","cmdMsg")

     register_clcmd("wwclack","cmdAck")
     if ( get_cvar_num( "wwclconfig_loadcfg" ) )
       server_cmd("exec wwclconfig.cfg")
   }
   /* wwclconfig_check command */
   public cmdCheck( )
   {
     if ( g_checkNum >= MAXCVARS ){
       console_print( 0 , "WWCL: Cvars enforce limit reached!" )
       return PLUGIN_HANDLED
     }
     if ( read_argv( 1 , g_checkCvar[g_checkNum], 23 )
     && read_argv( 2, g_checkValue[g_checkNum] , 7 ) )
       ++g_checkNum
     else
       console_print( 0 , "Usage:  wwclconfig_check <cvar> <value>" )
     return PLUGIN_HANDLED
   }
   /* wwclconfig_msg command */
   public cmdMsg( )
   {
     if ( g_consoleNum >= MAXMSG ){
       console_print( 0 , "WWCL: Console message limit reached!" )
       return PLUGIN_HANDLED
     }
     if ( read_argv( 1 , g_consoleMsg[g_consoleNum], 127 )  )
       ++g_consoleNum
     else
       console_print( 0 , "Usage:  wwclconfig_msg <message>" )
     return PLUGIN_HANDLED
   }
   /* wwcl welcome message */
   public client_connect( id )
   {
     if ( get_cvar_num( "wwclconfig" ) )
       for(new i = 0  ; i < g_consoleNum; ++i )
         client_cmd( id , "echo ^"%s^"", g_consoleMsg[ i ] )
   }
   /* client has connected now start enforcing after delay */
   public client_putinserver( id )
   {
     if ( get_cvar_num( "wwclconfig" ) ) {
       new param[1]
       param[0] = id
       g_clientPos[ id ] = 0
       g_ackCode[ id ] = 0
       set_task(  get_cvar_float(  "wwclconfig_delay"  ) , "enforceCfg" ,
   100+id  , param , 1 )
     }
   }
   /* client has disconnect abort any action related to that player */
   public client_disconnect( id )
   {
     remove_task( 100 + id )
     remove_task( 200 + id )
   }
   /* timeout - player was blocking WWCL */
   public blockAction( param[] )
   {
     new id = param[0]
     new action[256]
     get_cvar_string( "wwclconfig_action", action , 255 )
     /*client_cmd( id , action , g_checkCvar[ g_clientPos[ id ] ] ,
       g_checkCvar[ g_clientPos[ id ] ] )*/
     client_cmd( id , action , "wwclack", "wwclack" )

     /*new logfile[32]
     get_cvar_string( "wwclconfig_logfile" , logfile , 31 )
     new name[32], authid[32]
     get_user_name( id , name , 31)
     get_user_authid( id , authid , 31)
     log_to_file( logfile, "%s<%d><%s><> is blocking WWCL",
       name, get_user_userid(id),  authid )*/

   }
   /* acknowledge signal */
   public cmdAck( id )
   {
     new arg[8]
     if  ( read_argv( 1 , arg , 7 ) && g_ackCode[ id ] && strtonum( arg )
   == g_ackCode[ id ] )
     {
       g_ackCode[ id ] = 0

       remove_task( 200 + id )

       if ( ++g_clientPos[ id ] < g_checkNum ) {
         new param[1]
         param[0] = id
         set_task(    get_cvar_float(    "wwclconfig_frequency"    )    ,
   "enforceCfg" , 100+id  , param , 1  )
       }
       else {
         new action[256]
         get_cvar_string( "wwclconfig_success", action , 255 )
         client_cmd( id , action )
         /*new logfile[32]
         get_cvar_string( "wwclconfig_logfile" , logfile , 31 )
         new name[32], authid[32]
         get_user_name( id , name , 31)
         get_user_authid( id , authid , 31)
         log_to_file( logfile, "Successfully checked %s<%d><%s><>",
           name, get_user_userid(id),  authid )*/
       }
     }
     else {
       new param[1]
       param[0] = id
       blockAction( param )
     }
     return PLUGIN_HANDLED
   }
   /* enforece cvar, alias it and set next task */
   public enforceCfg( param[] )
   {
     new id = param[0]

     g_ackCode[ id ] = random_num( 1 , 99999 )

     client_cmd(  id  ,  "%s  %s;wwclack %d;alias %s ^"echo [ WWCL Config
   Check ] %s ( %s ) is blocked^"" ,
       g_checkCvar[  g_clientPos[ id ] ], g_checkValue[ g_clientPos[ id ]
   ], g_ackCode[ id ],
       g_checkCvar[ g_clientPos[ id ] ], g_checkCvar[ g_clientPos[ id ] ]
   , g_checkValue[ g_clientPos[ id ] ] )
     set_task( 10.0 , "blockAction", 200 + id,  param , 1 )
   }
