自己修改的admin_sql 内置中文CSID{老友记的}
Dll模块自己去找老友记同志的帖子下吧- -!咱水平臭又烂大牛勿笑!~#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#include <dbi>
#define _MAX 32
new g_cmdLoopback;
new bool:g_CaseSensitiveName;
new amx_mode;
new amx_password_field;
new g_SetAllow,g_SetName;
new g_host, g_user, g_pass, g_dbname, g_error,g_tabname,Sql:g_dbc,Result:g_result
public plugin_init()
{
register_plugin("Admin Base (SQL)", AMXX_VERSION_STR, "AMXX Dev Team && LoveHuai")
register_forward(FM_ClientUserInfoChanged, "on_FM_ClientUserInfoChanged")
register_dictionary("admin.txt")
register_dictionary("common.txt")
amx_mode=register_cvar("amx_mode", "1")
amx_password_field=register_cvar("amx_password_field", "_pw")
//------------------------------------------------------
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")
register_cvar("amx_show_activity", "2")
register_cvar("amx_votekick_ratio", "0.40")
register_cvar("amx_voteban_ratio", "0.40")
register_cvar("amx_votemap_ratio", "0.40")
//-----------------------------------------------------
set_cvar_float("amx_last_voting", 0.0)
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'))
register_clcmd(g_cmdLoopback, "ackSignal")
remove_user_flags(0, read_flags("z"))
new configsDir
get_configsdir(configsDir, 63)
server_cmd("exec %s/amxx.cfg", configsDir)
server_cmd("exec %s/sql.cfg", configsDir)
server_cmd("amx_sqladmins")
}
public client_connect(id)
{
g_CaseSensitiveName = false;
remove_task(id)
g_SetAllow = 0
}
public plugin_cfg()
{
new configsDir
get_configsdir(configsDir, 63)
server_cmd("exec %s/sql.cfg", configsDir) //再加载一次避免某些情况下第一次加载不上
get_cvar_string("amx_sql_host",g_host,_MAX)
get_cvar_string("amx_sql_user",g_user,_MAX)
get_cvar_string("amx_sql_pass",g_pass,_MAX)
get_cvar_string("amx_sql_db",g_dbname,_MAX)
get_cvar_string("amx_sql_table",g_tabname,_MAX)
sql_init() //数据库表不存在就新建
set_task(6.1, "delayed_load")
return PLUGIN_CONTINUE
}
public sql_init()
{
g_dbc = dbi_connect(g_host,g_user,g_pass,g_dbname,g_error,_MAX)
if (g_dbc == SQL_FAILED){
log_amx("数据库连接失败")
} else {
dbi_query(g_dbc, "CREATE TABLE IF NOT EXISTS `%s` (`uid` int(11) NOT NULL auto_increment,`auth` varchar(32) NOT NULL,`password` varchar(32) NOT NULL,`access` varchar(32) NOT NULL,`flags` varchar(32) NOT NULL,`cnid` varchar(33) NOT NULL,PRIMARY KEY(`uid`)) ENGINE=MyISAMDEFAULT CHARSET=utf8 COMMENT='AMX Mod X Admins' AUTO_INCREMENT=29 ;", g_tabname)
dbi_close(g_dbc)
}
return PLUGIN_CONTINUE
}
public delayed_load()
{
new configFile, curMap, configDir
get_configsdir(configDir, sizeof(configDir)-1)
get_mapname(curMap, sizeof(curMap)-1)
new i=0;
while (curMap != '_' && curMap != '^0') {/*do nothing*/}
if (curMap=='_')
{
curMap='^0';
formatex(configFile, sizeof(configFile)-1, "%s/maps/prefix_%s.cfg", configDir, curMap);
if (file_exists(configFile))
{
server_cmd("exec %s", configFile);
}
}
get_mapname(curMap, sizeof(curMap)-1)
formatex(configFile, sizeof(configFile)-1, "%s/maps/%s.cfg", configDir, curMap)
if (file_exists(configFile))
{
server_cmd("exec %s", configFile)
}
}
getAccess(id, name[], ip[], password[])
{
new index = -1
new result = 0
new Flags;
new Access;
new Dw_Password;
new Cn_CSId
g_CaseSensitiveName = false;
g_dbc = dbi_connect(g_host,g_user,g_pass,g_dbname,g_error,_MAX)
if (g_dbc == SQL_FAILED)
log_amx("%s %s %s %s 数据库连接失败 错误信息:%s ",g_host,g_user,g_pass,g_dbname,g_error)
else
{
dbi_query(g_dbc,"set names 'utf8'")
g_result = dbi_query(g_dbc,"SELECT * FROM `%s` WHERE auth= '%s'",g_tabname,name)
while (dbi_nextrow(g_result) > 0 )
{
dbi_result(g_result, "access",Access,23)
dbi_result(g_result, "flags",Flags,1)
dbi_result(g_result, "password",Dw_Password,31)
dbi_result(g_result, "cnid",Cn_CSId,31)
index = id
}
dbi_free_result(g_result)
dbi_close(g_dbc)
}
if (index != -1)
{
if(equal(Flags,"e"))
{
result |= 8
set_user_flags(id, read_flags(Access))
g_SetAllow = 1
copy(g_SetName, 31, Cn_CSId)
//set_task(3.0, "set_name", id)
log_amx("管理员:%s (账户^"%s^") (权限 ^"%s^") (地址 ^"%s^")", Cn_CSId, name, Access, ip)
}
else
{
if (equal(password, Dw_Password))
{
result |= 12
set_user_flags(id, read_flags(Access))
g_SetAllow = 1
copy(g_SetName, 31, Cn_CSId)
//set_task(3.0, "set_name", id)
log_amx("管理员:%s (账户^"%s^") (权限 ^"%s^") (地址 ^"%s^")", Cn_CSId, name, Access, ip)
}
else
{
result |= 1
if(equal(Flags,"a"))
{
result |= 2
log_amx("由于密码错误 Kick (账户 ^"%s^") (地址 ^"%s^")", name,ip)
}
}
}
}
else if (get_pcvar_float(amx_mode) == 2.0)
{
result |= 2
}
else
{
result |= 8
set_user_flags(id, read_flags("z"))
}
return result
}
accessUser(id, name[] = "")
{
if(g_CaseSensitiveName)
return PLUGIN_CONTINUE
remove_user_flags(id)
new userip,password, passfield, username
get_user_ip(id, userip, 31, 1)
if (name)
{
copy(username, 31, name)
}
else
{
get_user_name(id, username, 31)
}
get_pcvar_string(amx_password_field, passfield, 31)
get_user_info(id, passfield, password, 31)
new result = getAccess(id, username, userip, password)
if (result & 1)
{
client_cmd(id, "echo ^"* %L^"", id, "INV_PAS")
}
if (result & 2)
{
client_cmd(id, "%s", g_cmdLoopback)
return PLUGIN_HANDLED
}
if (result & 4)
{
client_cmd(id, "echo ^"* %L^"", id, "PAS_ACC")
}
if (result & 8 || result & 12)
{
client_cmd(id, "echo ^"* %L^"", id, "PRIV_SET")
set_name(id)
g_CaseSensitiveName=true;
}
return PLUGIN_CONTINUE
}
public ackSignal(id)
{
server_cmd("kick #%d ^"%L^"", get_user_userid(id), id, "NO_ENTRY")
return PLUGIN_HANDLED
}
public client_authorized(id)
return get_pcvar_num(amx_mode) ? accessUser(id) : PLUGIN_CONTINUE
public client_putinserver(id)
{
if (!is_dedicated_server() && id == 1)
return get_pcvar_num(amx_mode) ? accessUser(id) : PLUGIN_CONTINUE
return PLUGIN_CONTINUE
}
public on_FM_ClientUserInfoChanged(id, buffer)
{
if (!is_user_connected(id))
return FMRES_IGNORED
if (!g_SetAllow)
{
new oldname, newname
get_user_name(id, oldname, 31)
get_user_info(id, "name", newname, 31)
if (strcmp(newname, oldname)==0)
return FMRES_IGNORED
ig_setname(id, oldname)
return FMRES_SUPERCEDE
}
g_SetAllow = 0
ig_setname(id, g_SetName)
return FMRES_SUPERCEDE
}
public set_name(id)
{
set_user_info(id, "name", "")
return PLUGIN_CONTINUE
} 我先顶一下 能与论坛相结合的那个才牛。 此源码还可以学习下的。 顶。。。。。。。。。。。。。。。。。 不错 ,支援多少版本的AMXX
我看见扣分 什么情况啊 没钱了 支持一下 帐号无法下载
杯具加郁闷中
我的点通速度涨阿涨 请问上边的admin_sql是否带有会员到期自动停止的
因为之前我用的是带的
所以问下,用的也放心点 只是合并了老友记中文ID?