Raised This Month: $ Target: $400
 0% 

Load admins MySQL to users.ini


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        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 - 1145 views - 2.6 KB)
__________________
-> French user <- = english not good
MrHunt is offline
QwertyAccess
Veteran Member
Join Date: Feb 2004
Location: Enjiru Layer
Old 08-01-2004 , 00:11  
Reply With Quote #2

you dont have to upload the .amx file, and while personally i like it when people post the code you dont have to do that either, and you should use the small buttonw hen posting code.

Code:
//

Nice plugin though, what i needed
__________________
QwertyAccess is offline
Peli
Veteran Member
Join Date: Mar 2004
Location: San Diego, CA
Old 08-01-2004 , 00:12  
Reply With Quote #3

Helpful to a lot of people , nice plugin man. I agree with Qwerty , post your code in small tags and you can leave the rest because it's good.
Peli is offline
Send a message via MSN to Peli
MrHunt
Junior Member
Join Date: May 2004
Location: French Canadian
Old 08-01-2004 , 00:31  
Reply With Quote #4

ah its better like that ;)

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 code with a very simple code

I know that biloban have already modify the code of admin.amx to
merge it with mysql_admin like i tell him .. but is code is not simple like that
__________________
-> French user <- = english not good
MrHunt is offline
QwertyAccess
Veteran Member
Join Date: Feb 2004
Location: Enjiru Layer
Old 08-01-2004 , 00:37  
Reply With Quote #5

this way you dont need to define the amount of admins,
you might want to make it say steam only instead of 1.6 suggest you borrow/modify some code from the current admin_mysql

register_cvar("amx_mode","2.0")
register_cvar("amx_password_field","_pw")
register_cvar("amx_default_access","")

features like that need to be added.
__________________
QwertyAccess is offline
MrHunt
Junior Member
Join Date: May 2004
Location: French Canadian
Old 08-01-2004 , 00:39  
Reply With Quote #6

Quote:
Originally Posted by QwertyAccess
this way you dont need to define the amount of admins,
you might want to make it say steam only instead of 1.6
it's because i remove the password field in the database .. its not realy useful with the steamid

i will change it for steam only instead of 1.6 ..

Something more for you QwertyAccess ? ;)
__________________
-> French user <- = english not good
MrHunt is offline
MrHunt
Junior Member
Join Date: May 2004
Location: French Canadian
Old 08-01-2004 , 00:46  
Reply With Quote #7

This plugin replace admin_mysql BUT you still need admin.amx ..
Originaly i place this code in admin.sma but with the v0.20 .. i dont want the replace it again .. so i make a plugin with it ...
__________________
-> French user <- = english not good
MrHunt is offline
QwertyAccess
Veteran Member
Join Date: Feb 2004
Location: Enjiru Layer
Old 08-01-2004 , 01:04  
Reply With Quote #8

well then i assume you should load this plugin after admin plugin or it will cause problems, password field is often used to contain the person's name like
"STEAMID" "QWERTY" "ACCESS" "CE"

hmm in users.ini

"STEAM_0:1:1689" "" "Qwerty" "abcdefghijklmnopqrstu" ; ce
__________________
QwertyAccess is offline
QwertyAccess
Veteran Member
Join Date: Feb 2004
Location: Enjiru Layer
Old 08-01-2004 , 01:33  
Reply With Quote #9

u should replace with
Code:
    format(ligne,200,"^"%s^" ^"^" ^"%s^" ^"%s^"       ; %s", My_Auth, My_Access, My_Flags, My_nick)     format(ligne,200,"^"%s^" ^"%s^" ^"%s^" ^"%s^", My_Auth, My_Access, My_Flags, My_nick)
__________________
QwertyAccess is offline
MrHunt
Junior Member
Join Date: May 2004
Location: French Canadian
Old 08-01-2004 , 02:56  
Reply With Quote #10

Quote:
Originally Posted by QwertyAccess
u should replace with
Code:
    format(ligne,200,"^"%s^" ^"^" ^"%s^" ^"%s^"       ; %s", My_Auth, My_Access, My_Flags, My_nick)     format(ligne,200,"^"%s^" ^"%s^" ^"%s^" ^"%s^", My_Auth, My_Access, My_Flags, My_nick)
verify the result of my line :

"STEAM_0:1:XXXXXX" "" "abcdefghijklmnopqrstu" "ce" ; Mrhunt

it's ok

the nickname is good to see who have the steamid ...
__________________
-> French user <- = english not good
MrHunt is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:25.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode