View Single Post
Plugin Info:     Modification:          Category:         
MrHunt
Junior Member
Join Date: May 2004
Location: French Canadian
Old 08-01-2004 , 00:03   Load admins MySQL to users.ini
Reply With Quote #1

the reason of this plugin it if you lost the connection to your mysql database you still have your admins on your server ...

This code replace totally admin_mysql.amx code but you still need admin.amx with a very simple code


Code:
/******************************* * Load admins MySQL to users.ini * By Mr.Hunt & Gardor * <a href="mailto:[email protected]">[email protected]</a> * <a href="mailto:[email protected]">[email protected]</a> * * This plugin load your mysql admin * list to your user.ini file. Very simple * and useful plugin. For Steam only. * * Usage: * ====== * The admins are reloaded every maps * and you can reload it manualy. The * plugin automatically create your table * and fields in the database. * * amx_updateadmins * * Changelog: * ========== * 1.0 * -Initial Release * * ToDo: * ===== * *******************************/ #include <amxmodx> #include <amxmisc> #include <mysql> public plugin_init() {   register_plugin("Load Admin From Mysql","1.0","by MrHunt & Gardor")   register_srvcmd("amx_updateadmins","load_admins_mysql")   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","admins")   new configsDir[64]   get_configsdir(configsDir, 63)   server_cmd("exec %s/mysql.cfg", configsDir)   load_admins_mysql() } public load_admins_mysql() {   new host[64],user[32],pass[32],db[32],error[128]   get_cvar_string("amx_mysql_host",host,63)   get_cvar_string("amx_mysql_user",user,31)   get_cvar_string("amx_mysql_pass",pass,31)   get_cvar_string("amx_mysql_db",db,31)   new mysql = mysql_connect(host,user,pass,db,error,127)   if(mysql < 1)   {     server_print("[AMXX] MySQL error: can't connect: '%s'",error)     return PLUGIN_HANDLED   }   mysql_query(mysql,"CREATE TABLE IF NOT EXISTS admins ( auth varchar(32) NOT NULL default '', access varchar(32) NOT NULL default '', flags varchar(32) NOT NULL default 'ce',  nick varchar(32) NOT NULL default '' ) TYPE=MyISAM")   if(mysql_query(mysql,"SELECT * FROM admins") < 1)   {     mysql_error(mysql,error,127)     server_print("[AMXX] MySQL error: No admin's to load: '%s'",error)     return PLUGIN_HANDLED   }   new configsDir[64]   get_configsdir(configsDir, 63)   format(configsDir, 63, "%s/users.ini", configsDir)   delete_file(configsDir)   new My_Num = 0   new ligne[200]   new My_Auth[32],My_Access[32],My_Flags[32],My_nick[32]   while( mysql_nextrow(mysql) > 0 )   {     mysql_getfield(mysql, 1, My_Auth,31)     mysql_getfield(mysql, 2, My_Access,31)     mysql_getfield(mysql, 3, My_Flags,31)     mysql_getfield(mysql, 4, My_nick,31)     format(ligne,200,"^"%s^" ^"^" ^"%s^" ^"%s^"       ; %s", My_Auth, My_Access, My_Flags, My_nick)     write_file(configsDir,ligne,-1)     ++My_Num   }   mysql_close(mysql)   return PLUGIN_CONTINUE }
Attached Files
File Type: sma Get Plugin or Get Source (load_admin.sma - 1148 views - 2.6 KB)
__________________
-> French user <- = english not good
MrHunt is offline