
   /* AMX Mod script.
   *
   * (c) Copyright 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 admins table with this
   SQL query :
   CREATE TABLE maps (
     map varchar(32) NOT NULL default ''
   ) TYPE=MyISAM;
   If you will mapcycle for CS use this
   INSERT INTO maps VALUES ('de_dust');
   INSERT INTO maps VALUES ('de_inferno');
   INSERT INTO maps VALUES ('cs_siege');
   INSERT INTO maps VALUES ('de_survivor');
   INSERT INTO maps VALUES ('de_storm');
   INSERT INTO maps VALUES ('de_torn');
   INSERT INTO maps VALUES ('de_aztec');
   INSERT INTO maps VALUES ('as_oilrig');
   INSERT INTO maps VALUES ('de_vertigo');
   INSERT INTO maps VALUES ('de_cbble');
   INSERT INTO maps VALUES ('cs_747');
   INSERT INTO maps VALUES ('de_vegas');
   INSERT INTO maps VALUES ('de_prodigy');
   INSERT INTO maps VALUES ('cs_assault');
   INSERT INTO maps VALUES ('cs_office');
   INSERT INTO maps VALUES ('cs_italy');
   INSERT INTO maps VALUES ('cs_backalley');
   INSERT INTO maps VALUES ('cs_militia');
   INSERT INTO maps VALUES ('de_train');
   Notes :
   . check $moddir/addons/amx/mysql.cfg for MySQL access configuration
   */
   #include <amxmod>
   #include <mysql>
   public load_mapcycle()
   {
       new mysql,cnt
       new map[33]
       new error[257]
       new host[65]
       new user[33]
       new pass[33]
       new db[33]

       get_cvar_string("amx_mysql_host",host,64)
       get_cvar_string("amx_mysql_user",user,32)
       get_cvar_string("amx_mysql_pass",pass,32)
       get_cvar_string("amx_mysql_db",db,32)
       mysql = mysql_connect(host,user,pass,db,error,256)
       if(mysql>0)
       {
           if(mysql_query(mysql,"SELECT map FROM maps")>0)
           {
               cnt = 0
               delete_file("mapcycle.txt")
               while(mysql_nextrow(mysql)>0)
               {
                   mysql_getfield(mysql,1,map,32)

                   write_file("mapcycle.txt",map,-1)

                   cnt++
               }
               server_print("[AMX] Loaded %d map(s) from database",cnt)
           }
           else
           {
               mysql_error(mysql,error,32)
               server_print("MySQL  error  :  could  not  load mapcycle :
   '%s'",error)
           }
           mysql_close(mysql)
       }
       else
       {
           server_print("MySQL error : could not connect : '%s'",error)
       }
       return PLUGIN_HANDLED
   }
   public plugin_init()
   {
       register_plugin("Mapcycle from MySQL","0.2","Noplay")
       register_cvar("amx_mysql_host","127.0.0.1")
       register_cvar("amx_mysql_user","root")
       register_cvar("amx_mysql_pass","")
       register_cvar("amx_mysql_db","amx")
       set_task(5.0,"load_mapcycle")
       return PLUGIN_CONTINUE
   }
