集成SXE截图封禁机器码数据库保存
本帖最后由 Village 于 2011-1-17 15:26 编辑找到这样的一个插件,但是不能正常运行!希望广大高手可以修改此问题!
明明连接到数据库了,数据库已经自动创建了表格,但是只要封禁玩家就使服务器挂掉!提示不能连接到数据库!
请看下面重启服务器时的错误日子:Start of error session.
L 01/17/2011 - 02:45:50: Info (map "de_dust2") (logfile "error_011711.log")
L 01/17/2011 - 02:45:50: Plugin ("sxe.amxx") is setting itself as failed.
L 01/17/2011 - 02:45:50: Plugin says: Could not connect to SQL database.
L 01/17/2011 - 02:45:50: Displaying debug trace (plugin "sxe.amxx")
L 01/17/2011 - 02:45:50: Run time error 1: forced exit
L 01/17/2011 - 02:45:50: sxe.sma::SQL_QueryHandle (line 283)
翻译中文为:开始的误差会议。
我01/17/2011 - 02:45:50 Info(地图””)(de_dust2日志文件中“error_011711.log”)
我01/17/2011 - 02:45:50:的插件(“sxe.amxx”)是建立本身就失败了。
我01/17/2011 - 02:45:50:插件说:不可以连接到的SQL数据库。
我01/17/2011 - 02:45:50:显示调试跟踪sxe.amxx”)插件”
我01/17/2011 - 02:45:50:运行时错误1:被迫退出
我01/17/2011 - 02:45:50:sxe.sma:SQL_QueryHandle(第283)
顺便问问怎么修改权限sXe Bans 3.0
Dejo la última versión del sXe Bans que utilizo en mis servidores la cual contiene:
sXe Screenshot: Le saca una screenshot al usuario.
- amx_sxe_screen "nick"
sXe Ban: Bannea a un usuario, se puede especificar o no una razón.
- amx_sxe_ban "nick" "razon"
- amx_sxe_menu
sXe UnBan: Permite sacar un ban sin la necesidad de ingresar al FTP del servidor.
- amx_sxe_unban num (ej en amx_sxe_banlist)
sXe BanList: Muestra la cantidad de usuarios banneados por sXe Injected y la razón si es que existe.
- amx_sxe_banlist
El plugin para funcionar necesita una base de datos y tener instalado el Orpheu (viene incluído en el ZIP).
Para configurar la base de datos ingresen a addons/amxmodx/configs/sql.cfg y completan los datos que se piden y el plugin crea automáticamente la tabla con sus respectivas columnas.
急等修复此问题!RMB答谢解决问题者! 源码#include <amxmodx>
#include <amxmisc>
#include <orpheu>
#include <sqlx>
#pragma semicolon 1;
#define PLUGIN "sXeI Ban Local"
#define VERSION "3.0"
#define AUTHOR "ILUSION"
#define FLAG_SCREEN ADMIN_KICK // Acceso requerido para sacar una screenshot en algun usuario. No es importan tener tanto acceso ya que no podra hacer nada malo
#define FLAG_BAN ADMIN_LEVEL_H // Acceso requerido para los usuarios que poseen acceso al sXe Ban
#define MASTER_BAN ADMIN_RCON // Acceso requerido para los usuarios que poseen permiso para bannear otros administradores (inclusive con inmunidad)
#define sxe_file "sxe_local_ban.cfg"
new MenuCallback, pointer;
new sXeHID;
new Handle:g_SqlTuple;
new cvar_host, cvar_db, cvar_user, cvar_pass;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_concmd("amx_sxe_ban", "cmdBan", FLAG_BAN, "<nick> <razon>");
register_concmd("amx_sxe_menu", "cmdBanMenu", FLAG_BAN);
register_concmd("amx_sxe_screen", "cmdScreen", FLAG_SCREEN, "<nick>");
register_concmd("amx_sxe_banlist", "cmdBanList", FLAG_SCREEN);
register_concmd("amx_sxe_unban", "cmdUnBan", MASTER_BAN, "<id>");
register_cvar("amx_sxe_bans", VERSION, FCVAR_SERVER); // CVAR GLOBAL - NO TOCAR!
cvar_host = get_cvar_pointer("amx_sql_host");
cvar_db = get_cvar_pointer("amx_sql_db");
cvar_user = get_cvar_pointer("amx_sql_user");
cvar_pass = get_cvar_pointer("amx_sql_pass");
new Host, Db, User, Pass;
get_pcvar_string(cvar_host, Host, charsmax(Host));
get_pcvar_string(cvar_db, Db, charsmax(Db));
get_pcvar_string(cvar_user, User, charsmax(User));
get_pcvar_string(cvar_pass, Pass, charsmax(Pass));
g_SqlTuple = SQL_MakeDbTuple(Host, User, Pass, Db);
SQL_ThreadQuery(g_SqlTuple, "SQL_QueryHandle", "CREATE TABLE IF NOT EXISTS `sxebans` ( `id` INT( 32 ) NOT NULL AUTO_INCREMENT, `nick` VARCHAR( 32 ) NOT NULL, `ip` VARCHAR( 18 ) NOT NULL, `hid` VARCHAR( 34 ) NOT NULL, `admin` VARCHAR( 64 ) NOT NULL, `razon` VARCHAR( 250 ) NOT NULL default '-', PRIMARY KEY (`id`) ) COMMENT = 'sXe Bans'");
pointer = get_cvar_pointer("__sxei_required");
}
public plugin_cfg()
server_cmd("amx_pausecfg add ^"%s^"", PLUGIN);
public cmdBan(id, level, cid)
{
if (!cmd_access(id, level, cid, 2) || !get_pcvar_num(pointer))
return PLUGIN_HANDLED;
new arg, razon;
read_argv(1, arg, charsmax(arg));
read_argv(2, razon, charsmax(razon));
new target;
if (get_user_flags(id) & MASTER_BAN)
target = cmd_target(id, arg, CMDTARGET_ALLOW_SELF);
else
target = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY);
if (!target)
return PLUGIN_HANDLED;
remove_quotes(razon);
funcion(id, target, razon);
return PLUGIN_HANDLED;
}
public cmdBanMenu(id, level, cid)
{
new name;
get_user_name(id, name, charsmax(name));
if (!cmd_access(id, level, cid, 1) || !get_pcvar_num(pointer))
return PLUGIN_HANDLED;
new menu = menu_create("\wsXe Ban Menu", "menu_handler");
new players, pnum, tempid;
new szName, szTempid;
get_players(players, pnum);
MenuCallback = menu_makecallback("callback");
new items;
for (new i; i < pnum; i++)
{
tempid = players;
get_user_name(tempid, szName, 31);
num_to_str(tempid, szTempid, 9);
formatex(items, charsmax(items), "%s%s", szName, is_user_admin(tempid) ? "\r *" : "");
if (get_user_flags(tempid) & ADMIN_IMMUNITY && !(get_user_flags(id) & MASTER_BAN) || get_user_flags(tempid) & MASTER_BAN)
menu_additem(menu, items, szTempid, 0, MenuCallback);
else
menu_additem(menu, items, szTempid, 0);
}
menu_setprop(menu, MPROP_BACKNAME, "Atras");
menu_setprop(menu, MPROP_NEXTNAME, "Siguiente");
menu_setprop(menu, MPROP_EXITNAME, "Salir");
menu_display(id, menu, 0);
return PLUGIN_HANDLED;
}
public cmdScreen(id, level, cid)
{
if (!cmd_access(id, level, cid, 2) || !get_pcvar_num(pointer))
return PLUGIN_HANDLED;
new arg;
read_argv(1, arg, charsmax(arg));
new target = cmd_target(id, arg, CMDTARGET_ALLOW_SELF);
if (!target)
return PLUGIN_HANDLED;
new name;
get_user_name(target, name, charsmax(name));
if (is_user_bot(target) || is_user_hltv(target))
{
console_print(id, "No se le puede sacar una screenshot a %s debido a que es un %s", name, is_user_bot(id) ? "bot" : "HLTV");
return PLUGIN_HANDLED;
}
server_cmd("sxe_screen #%d #%d", get_user_userid(target), get_user_userid(id));
console_print(id, "Comenzo la transferencia de la screenshot de %s", name);
return PLUGIN_HANDLED;
}
public cmdBanList(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED;
new data; data = id;
SQL_ThreadQuery(g_SqlTuple, "SQL_BanList", "SELECT id, nick, ip, admin, razon FROM sxebans", data, 1);
return PLUGIN_HANDLED;
}
public cmdUnBan(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED;
new arg;
read_argv(1, arg, charsmax(arg));
new Query, data;
data = id;
formatex(Query, charsmax(Query), "SELECT id, nick, hid FROM sxebans WHERE id = %s", arg);
SQL_ThreadQuery(g_SqlTuple, "SQL_UnBan", Query, data, 1);
return PLUGIN_HANDLED;
}
public callback(id, menu, item)
return ITEM_DISABLED;
public menu_handler(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data, iName;
new mnw, callback;
menu_item_getinfo(menu, item, mnw, data,5, iName, 63, callback);
new target = str_to_num(data);
if (is_user_connected(target))
funcion(id, target);
return PLUGIN_HANDLED;
}
funcion(id, target, const razon[] = "")
{
new nuser, nadmin, ip;
get_user_name(id, nadmin, charsmax(nadmin));
get_user_name(target, nuser, charsmax(nuser));
get_user_ip(target, ip, charsmax(ip), 1);
if (is_user_bot(target) || is_user_hltv(target))
{
new msg;
formatex(msg, charsmax(msg), "%s no puede ser banneado debido a que es un %s", nuser, is_user_bot(id) ? "bot" : "HLTV");
console_print(id, msg);
return PLUGIN_HANDLED;
}
new OrpheuHook:handlePrintf = OrpheuRegisterHook(OrpheuGetFunction("Con_Printf"), "Con_Printf");
server_cmd("sxe_userhid #%d", get_user_userid(target));
server_exec();
OrpheuUnregisterHook(handlePrintf);
// mensaje: sxei_userhid:
replace(sXeHID, charsmax(sXeHID), "sxei_userhid: ", "");
replace(sXeHID, charsmax(sXeHID), "[", "");
replace(sXeHID, charsmax(sXeHID), "]", ""); 接上面的第236行开始trim(sXeHID);
client_cmd(0, "spk ^"vox/hello and die^"");
client_print(0, print_chat, "<< sXe Injected >>");
client_print(0, print_chat, "NICK: %s || IP: %s", nuser, ip);
client_print(0, print_chat, "CASTIGO: Ban Local");
log_amx("ADMIN: %s banneo a %s via sXe Injected", nadmin, nuser);
replace_all(nuser, charsmax(nuser), "'", "''");
replace_all(nadmin, charsmax(nadmin), "'", "''");
new g_query, data;
data = id;
if (razon)
{
client_print(0, print_chat, "RAZON: %s", razon);
client_print(target, print_console, "Fuiste banneado del servidor via sXe Injected");
client_print(target, print_console, "La razon de tu ban fue: %s", razon);
formatex(g_query, charsmax(g_query), "INSERT INTO sxebans (nick, ip, hid, admin, razon) VALUES ('%s', '%s', '%s', '%s', '%s', %s)", nuser, ip, sXeHID, nadmin, razon);
}
else
{
client_print(target, print_console, "Fuiste banneado del servidor via sXe Injected");
client_print(target, print_console, "La razon de tu ban fue: -");
formatex(g_query, charsmax(g_query), "INSERT INTO sxebans (nick, ip, hid, admin, server) VALUES ('%s', '%s', '%s', '%s')", nuser, ip, sXeHID, nadmin);
}
server_cmd("sxe_ban ^"#%d^"", get_user_userid(target));
SQL_ThreadQuery(g_SqlTuple, "SQL_QueryHandle", g_query, data, 1);
return PLUGIN_HANDLED;
}
public OrpheuHookReturn:Con_Printf(const a[], const message[])
{
copy(sXeHID, charsmax(sXeHID), message);
return OrpheuSupercede;
}
public SQL_QueryHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
if(FailState == TQUERY_CONNECT_FAILED)
return set_fail_state("Could not connect to SQL database.");
else if(FailState == TQUERY_QUERY_FAILED)
return set_fail_state("Query failed.");
if(Errcode)
return log_amx("Error on query: %s",Error);
return PLUGIN_CONTINUE;
}
public SQL_BanList(FailState, Handle:Query, Error[], Errcode, Data[], DataSize[])
{
if(FailState == TQUERY_CONNECT_FAILED)
return set_fail_state("Could not connect to SQL database.");
else if(FailState == TQUERY_QUERY_FAILED)
return set_fail_state("Query failed.");
if(Errcode)
return log_amx("Error on query: %s",Error);
new id = Data;
if (!SQL_NumResults(Query))
{
console_print(id, "No hay usuarios banneados.");
return PLUGIN_CONTINUE;
}
new qID = SQL_FieldNameToNum(Query, "id");
new qName = SQL_FieldNameToNum(Query, "nick");
new qAdmin = SQL_FieldNameToNum(Query, "admin");
new qRazon = SQL_FieldNameToNum(Query, "razon");
new qIP = SQL_FieldNameToNum(Query, "ip");
new uID, uName, uIP, uAdmin, uRazon;
new bans;
while(SQL_MoreResults(Query))
{
SQL_ReadResult(Query, qID, uID, charsmax(uID));
SQL_ReadResult(Query, qName, uName, charsmax(uName));
SQL_ReadResult(Query, qIP, uIP, charsmax(uIP));
SQL_ReadResult(Query, qAdmin, uAdmin, charsmax(uAdmin));
SQL_ReadResult(Query, qRazon, uRazon, charsmax(uRazon));
console_print(id, "#%s.NICK: %s - IP: %s - ADMIN: %s - RAZON: %s", uID, uName, uIP, uAdmin, uRazon);
++bans;
SQL_NextRow(Query);
}
console_print(id, "^nsXe Bans: %d - Para remover un ban usar amx_sxe_unban < id >", bans);
return PLUGIN_CONTINUE;
}
public SQL_UnBan(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
if(FailState == TQUERY_CONNECT_FAILED)
return set_fail_state("Could not connect to SQL database.");
else if(FailState == TQUERY_QUERY_FAILED)
return set_fail_state("Query failed.");
if(Errcode)
return log_amx("Error on query: %s",Error);
new id = Data;
if (!SQL_NumResults(Query))
{
console_print(id, "ID invalido.");
return PLUGIN_CONTINUE;
}
new name;
get_user_name(id, name, charsmax(name));
new qID = SQL_FieldNameToNum(Query, "id");
new qName = SQL_FieldNameToNum(Query, "nick");
new qHID = SQL_FieldNameToNum(Query, "hid");
new uID, uName, uHID;
while(SQL_MoreResults(Query))
{
SQL_ReadResult(Query, qID, uID, charsmax(uID));
SQL_ReadResult(Query, qName, uName, charsmax(uName));
SQL_ReadResult(Query, qHID, uHID, charsmax(uHID));
log_amx("ADMIN %s: le saco el ban a %s (N. #%s)", name, uName, uID);
console_print(id, " Le sacaste el ban a %s (N. #%s)", uName, uID);
SQL_NextRow(Query);
}
new error, errno;
new Handle:Remove = SQL_Connect(g_SqlTuple, errno, error, charsmax(error));
SQL_QueryAndIgnore(Remove, "DELETE FROM sxebans WHERE id = %s", uID);
SQL_FreeHandle(Remove);
new file = fopen(sxe_file, "rt");
new szLine, linea;
while(!feof(file))
{
fgets(file, szLine, charsmax(szLine));
trim(szLine);
if (equal(szLine, uHID))
{
write_file(sxe_file, "", linea);
delete_empty_lines(sxe_file);
break;
}
linea++;
}
fclose(file);
return PLUGIN_CONTINUE;
}
/* Exolent */
delete_empty_lines(const filename[])
{
static const temp_filename[] = "tempfile.txt";
new f = fopen(filename, "rt");
if (!f) return -1;
new lines = 0;
new t = fopen(temp_filename, "wt");
static data;
while (!feof(f))
{
fgets(f, data, sizeof(data) - 1);
if( data && data != '^n' )
{
fputs(t, data);
}
else
{
lines++;
}
}
fclose(f);
fclose(t);
delete_file(filename);
rename_file(temp_filename, filename, 1);
return lines;
}
/* Exolent */
public plugin_end()
SQL_FreeHandle(g_SqlTuple); 如果有意者不愿意分享修改好的可以加我QQ私聊:1178158588 急等解决!顶起来! 再次顶起! 急等高手解决!以RMB回报! 本帖最后由 lovehuai 于 2011-1-26 13:28 编辑
trim(sXeHID);
这个是特征码吧
封成模块要么
粗略看了下代码
Sxe的Ban跟HLDS的一样是写Cfg的
Ban的时候 Sxe的模块会写入Cfg 然后插件写到数据库
UnBan把被封的从Cfg中删除
这玩意你用不用数据库都行啊
难道Sxe会删除那个Cfg?
除非你是多个服务器同步Bans列表否者完全用不上啊 这个插件用的是异步线程来连接数据库的,每次执行查询都要重新连接MYSQL。
不过从代码看似乎没什么问题.
页:
[1]