

/* AMX Mod script. 
* 
* (c) Copyright 2002, Noplay 
* This file is provided as is (no warranties). 
* 
*/ 

/* 
reads te filename and content form sql and writes to a regular hdd file on server
good for spreading the same settings for many servers with a rare usage of sql on them


This AMX plugin requires MySQL MetaSmall module. 

For this to work, you might create your MySQL table with this SQL query : 

CREATE TABLE `files` ( 
`file` VARCHAR(64) NOT NULL, 
`content` MEDIUMTEXT NOT NULL, 
UNIQUE (`file`) 
); 


Notes : 
. check $moddir/addons/amx/mysql.cfg for MySQL access configuration 


it is limited to 1500 chars, it's a limit of smallC


you install the plugin on your serv 
you configure your addons/amx/mysql.cfg 
and in you Mysql DataBase you insert for example 
file: 
Code: 
motd.txt 
content: 
Code: 
Cool It's my MOTD.txt from MySQL 

file: 
Code: 
mapcycle.txt 

content: 
Code: 
de_dust 
de_dust2 


names can contain subdirs (they must exist)
motd.txt 
mapcycle.txt 
addons/amx/conmotd.txt 





aditionally
the problem is the new version of Hlds who load only one time the server.cfg 
If you will execute your server.cfg to every maps you can use this very small plugin, i think that's work 
AMX Code: 

public plugin_init() 
{ 
   register_plugin("Server CFG","0.1","Noplay") 

   server_cmd("exec server.cfg") 

    
   return PLUGIN_CONTINUE 
} 



 





*/ 

#include <amxmod> 
#include <mysql> 

public load_files() 
{ 
   new mysql,cnt 
   new file[65] 
   new content[3025] 
   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 file,content FROM files")>0) 
      { 
         cnt = 0 
         while(mysql_nextrow(mysql)>0) 
         { 
            mysql_getfield(mysql,1,file,32) 
            mysql_getfield(mysql,2,content,3024) 
             
            delete_file(file) 
            write_file(file,content); 
             
            cnt++ 
         } 
         server_print("[AMX] Loaded %d file(s) from database",cnt) 
      } 
      else 
      { 
         mysql_error(mysql,error,32) 
         server_print("MySQL error : could not load file : '%s'",error) 
      } 
      mysql_close(mysql) 
   } 
   else 
   { 
      server_print("MySQL error : could not connect : '%s'",error) 
   } 
   return PLUGIN_HANDLED 
} 

public plugin_init() 
{ 
   register_plugin("Files 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_files") 
   return PLUGIN_CONTINUE 
} 


