Hi, I've been using the script below for alot of time, both for AMX amd AMXX - originally developed by NoPlay and slightly modified by my self for supporting multiple servers and suiting my needs.
To night i wanted to start upgrading my servers for version 1.0 of AMXX, but this very important plugin to me doesn't work after being compiled for AMXX.
Since it's a very small plugin i asumed that it wouldn't be hard for an expirienced small programmer to correct it or make an alternative, so therefore i guessed it would be worth a shot posting it here.
Code:
/* AMX Mod script.
*
* (c) Copyright 2002, Noplay
* This file is provided as is (no warranties).
*
*/
/*
This AMX plugin requires MySQL MetaSmall module.
For the plugin to work, you need the MySQL table, it can be created with this SQL query:
CREATE TABLE `amx_files` (
`id` int(11) NOT NULL auto_increment,
`serverid` int(11) NOT NULL default '0',
`file` varchar(100) NOT NULL default '',
`content` mediumtext NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;
To configure your MySQL informations, go to the addons/amx/mysql.cfg file and edit it.
Files specified with the serverid 0 will be loaded at all servers, files with a special serverid
will only be loaded at the servers configured with that serverid.
To set your servers serverid, type this in your server config: amx_serverid X
replace X with your servers id (eg. amx_serverid 1).
OBS!
This plugin was original developed by NoPlay, and re-written for multiply server support by FeliX.
Thanks to GeekGod for help.
*/
#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]
// GG
new string[98]
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)
{
format(string,98,"SELECT file,content FROM amx_files where serverid = 0 or serverid = %d order by serverid ASC",get_cvar_num("amx_serverid"))
if(mysql_query(mysql,string) >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("[AMX] MySQL error : could not load file : '%s'",error)
}
mysql_close(mysql)
}
else
{
server_print("[AMX] MySQL error : could not connect : '%s'",error)
}
return PLUGIN_HANDLED
}
public plugin_init()
{
register_plugin("MySQL Files","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")
register_cvar("amx_serverid","1")
set_task(5.0,"load_files")
server_cmd("exec server.cfg")
return PLUGIN_CONTINUE
}
When running it on my AMX Mod X based server I'm getting a fatal error causing the server to crash: