|
楼主 |
发表于 2011-1-17 15:15:40
|
显示全部楼层
来自 中国–内蒙古–呼和浩特
源码- #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[72];
- 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[32], Db[32], User[32], Pass[32];
- 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[32], razon[64];
-
- 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[32];
- 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[32], pnum, tempid;
-
- new szName[32], szTempid[10];
-
- get_players(players, pnum);
-
- MenuCallback = menu_makecallback("callback");
-
- new items[32];
-
- for (new i; i < pnum; i++)
- {
- tempid = players[i];
- 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[32];
- read_argv(1, arg, charsmax(arg));
-
- new target = cmd_target(id, arg, CMDTARGET_ALLOW_SELF);
-
- if (!target)
- return PLUGIN_HANDLED;
-
- new name[32];
- 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[1]; data[0] = 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[4];
- read_argv(1, arg, charsmax(arg));
-
- new Query[72], data[1];
- data[0] = 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[6], iName[64];
- 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[32], nadmin[64], ip[32];
-
- 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[192];
- 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: [XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX]
- replace(sXeHID, charsmax(sXeHID), "sxei_userhid: ", "");
- replace(sXeHID, charsmax(sXeHID), "[", "");
- replace(sXeHID, charsmax(sXeHID), "]", "");
复制代码 |
|