From e6ebccd26922e2adcfe4b09158336476bdad9367 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sun, 7 Mar 2004 10:57:57 +0000 Subject: [PATCH] added amx_reloadadmins --- plugins/admin.sma | 27 ++++++++++++++++++++++----- plugins/admin_mysql.sma | 18 +++++++++++++++--- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/plugins/admin.sma b/plugins/admin.sma index b88aebeb..2e56975e 100755 --- a/plugins/admin.sma +++ b/plugins/admin.sma @@ -40,7 +40,7 @@ new g_aPassword[MAX_ADMINS][32] new g_aName[MAX_ADMINS][32] new g_aFlags[MAX_ADMINS] new g_aAccess[MAX_ADMINS] -new g_aNum +new g_aNum = 0 #if !defined NO_STEAM new g_cmdLoopback[16] #endif @@ -52,13 +52,15 @@ public plugin_init() register_cvar("amx_password_field","_pw") register_cvar("amx_default_access","") - register_cvar("amx_vote_ratio","0.02") - register_cvar("amx_vote_time","10") - register_cvar("amx_vote_answers","1") + register_cvar("amx_vote_ratio","0.02") + register_cvar("amx_vote_time","10") + register_cvar("amx_vote_answers","1") register_cvar("amx_vote_delay","60") register_cvar("amx_last_voting","0") set_cvar_float("amx_last_voting",0.0) + register_concmd("amx_reloadadmins","cmdReload",ADMIN_ADMIN) + #if !defined NO_STEAM format( g_cmdLoopback, 15, "amxauth%c%c%c%c" , random_num('A','Z') , random_num('A','Z') ,random_num('A','Z'),random_num('A','Z') ) @@ -96,10 +98,25 @@ loadSettings(szFilename[]) g_aFlags[ g_aNum ] = read_flags( szFlags ) ++g_aNum } - + server_print("Loaded %d admin%s from file",g_aNum, (g_aNum == 1) ? "" : "s" ) return 1 } +public cmdReload(id,level,cid) +{ + if (!cmd_access(id,level,cid,1)) + return PLUGIN_HANDLED + + new filename[64] + get_basedir(filename,31) + format(filename,63,"%s/configs/users.ini",filename) + + g_aNum = 0 + loadSettings(filename) // Re-Load admins accounts + + return PLUGIN_HANDLED +} + getAccess(id,name[],authid[],ip[], password[]) { new index = -1 diff --git a/plugins/admin_mysql.sma b/plugins/admin_mysql.sma index 1e679bce..1e4aa8c9 100755 --- a/plugins/admin_mysql.sma +++ b/plugins/admin_mysql.sma @@ -40,7 +40,7 @@ new g_aPassword[MAX_ADMINS][32] new g_aName[MAX_ADMINS][32] new g_aFlags[MAX_ADMINS] new g_aAccess[MAX_ADMINS] -new g_aNum +new g_aNum = 0 #if !defined NO_STEAM new g_cmdLoopback[16] #endif @@ -67,6 +67,8 @@ public plugin_init() register_cvar("amx_vote_delay","60") register_cvar("amx_last_voting","0") set_cvar_float("amx_last_voting",0.0) + + register_concmd("amx_reloadadmins","cmdReload",ADMIN_ADMIN) #if !defined NO_STEAM format( g_cmdLoopback, 15, "amxauth%c%c%c%c" , @@ -82,7 +84,7 @@ public plugin_init() server_cmd("exec %s/configs/mysql.cfg;amx_sqladmins" , filename) } -public adminSql(){ +public adminSql() { 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) @@ -104,7 +106,6 @@ public adminSql(){ } new szFlags[32],szAccess[32] - g_aNum = 0 /* reset admins settings */ while( mysql_nextrow(mysql) > 0 ) { mysql_getfield(mysql, 1, g_aName[ g_aNum ] ,31) @@ -125,6 +126,17 @@ public adminSql(){ return PLUGIN_HANDLED } +public cmdReload(id,level,cid) +{ + if (!cmd_access(id,level,cid,1)) + return PLUGIN_HANDLED + + g_aNum = 0 + adminSql() // Re-Load admins accounts + + return PLUGIN_HANDLED +} + getAccess(id,name[],authid[],ip[], password[]){ new index = -1 new result = 0