
   /* AMXMOD script.
   *
   * (c) Copyright 2000-2002, Noplay
   * This file is provided as is (no warranties).
   *
   */
   /*
   This AMX plugin requires MySQL MetaSmall module.
   For  this  to  work,  you  might create your MySQL table with this SQL
   query :
   CREATE TABLE `say` (
   `srv` TINYINT( 4 ) NOT NULL ,
   `player_name` VARCHAR( 32 ) NOT NULL ,
   `say` VARCHAR( 128 ) NOT NULL
   );
   Notes :
   . check $moddir/addons/amx/mysql.cfg for MySQL access configuration
   */
   /*
   All server need have an unique ID give by the cvar amx_server_id
   you can this in addons/amx/phpamx.cfg file
   for example:
   amx_server_id "1"
   If you have many server on the same computer and on different port,
   i recommend to use the PORT.cfg amx plugin
   */
   #include <amxmod>
   #include <mysql>
   new srv_id[5]
   new mysql
   new merror[257]
   new mhost[65]
   new muser[33]
   new mpass[33]
   new mdb[33]
   new mquery[256]
   new state=0
   public log_sql(id)
   {
       if (state==0)
       {
           sql_init()
       }

       new said[129]
       new player_name[33]
       read_args(said,128)

       get_user_name(id,player_name,32)

       format(mquery,255,"INSERT  INTO `say` (srv,player_name,say) values
   ('%s','%s','%s')",srv_id,player_name,said)
       mysql_query(mysql,mquery)
       mysql_error(mysql,merror,31)

       if (merror[0])
       {
           server_print("[AMX] MYSQL error: %s",merror)
       }

       return PLUGIN_CONTINUE
   }
   public plugin_end()
   {
       if (mysql > 0)
       {
           mysql_close(mysql)
       }

       return PLUGIN_CONTINUE
   }
   public sql_init()
   {
       get_cvar_string("amx_mysql_host",mhost,64)
       get_cvar_string("amx_mysql_user",muser,32)
       get_cvar_string("amx_mysql_pass",mpass,32)
       get_cvar_string("amx_mysql_db",mdb,32)


       mysql = mysql_connect(mhost,muser,mpass,mdb,merror,256)
       if(mysql < 1)
       {
           server_print("[AMX]   MySQL   error  :  could  not  connect  :
   '%s'",merror)
       }

       if (merror[0])
       {
           server_print("[AMX] MYSQL error: %s",merror)
          }
       state=1

       get_cvar_string("amx_server_id",srv_id,4)

       return PLUGIN_CONTINUE
   }
   public plugin_init()
   {
       register_plugin("Mysql log say","0.1","Noplay")
       register_clcmd("say","log_sql")
       register_clcmd("say_team","log_sql")

       register_cvar("amx_server_id","0")
       server_cmd("exec addons/amx/phpamx.cfg")

       return PLUGIN_CONTINUE
   }
