soap
Участник
- Сообщения
- 3
- Реакции
- 0
Здравствуйте, у меня на сервере стоит античит UCP 7.0 и плагин noucp.amxx который позволяет заходить игрокам и без античита, но к игрокам без античита UCP он добавляет тег "[NO-UCP] " Как сделать что бы он не добавлял тег !? Помогите
C-подобный:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <ip>
#include <regex>
#define KickReason "CETb 3A6AHEHA! DOCTY/7 -> example.ru"
#define PROTECTED_ADMIN ADMIN_BAN
#define PROTECTED_USER ADMIN_LEVEL_G
// Comment to disable
//#define ACCEPT_ADMIN // Accept users with flag PROTECTED_ADMIN
//#define ACCEPT_USER // Accept users with flag PROTECTED_USER
//#define ACCEPT_STEAM // Accept users with steamid STEAM_0:
//#define ACCEPT_REVEMU // Accept users with steamid VALVE_0:
//#define ACCEPT_SUBNET // Accept users from allowed subnet
#define TAG_EVERYONE // Accept everyone and set tag for users without ucp. This ignores ACCEPT_* settings
// Uncomment only one:
// false for blacklist, true for whitelist
#define SUBNET_REVERSE false
//#define SUBNET_REVERSE true
new _debug = 1 // log info about every connect?
#define TASK_ID 9871 // For tag adding. Bounds 0..32. Change if overlap with other plugins
//##############################################################
// [Credits]
// jim_yang for amx_logged forward
// Hawk552 for CreateMultiForward
// Zefir for ip.inc
// Z@C,NO PASARAN,RUNET for BanSubnets
// max_rip for regex
#define PLUGIN "No-UCP"
#define VERSION "1.5"
#define AUTHOR "VoidLess"
#define NU_NOTCHECKED 0
#define NU_CHECKED 1
#define NU_HASUCP 2
new checked[33] // checked for access
new g_names[33][33] // name db for search
new Regex:compiledPattern
#if defined ACCEPT_SUBNET
new Array:g_networks
new g_network_num
new DeniedFile[64]
#endif
public plugin_init()
{
register_plugin(PLUGIN,VERSION,AUTHOR)
register_srvcmd("kzck", "KickIgnore", -1)
static error[100]
new ret
compiledPattern = regex_compile("^^Login NO-UCP: <(.+)> <[0-9.]+> <[A-Za-z_0-9:]+>$",ret,error,sizeof error)
if (ret < 0) set_fail_state(error)
#if defined ACCEPT_SUBNET
static confdir[64]
get_configsdir(confdir, 63)
format(DeniedFile, 63, "%s/BanSubnets/Denied2.ini", confdir)
g_networks = ArrayCreate(32, 10)
read_networks()
log_amx("Startup: read %d banned networks", g_network_num )
#endif
}
public plugin_natives()
{
register_native("has_user_ucp", "native_has_user_ucp")
}
public client_connect(id)
{
if(id != 0)
{
checked[id] = NU_NOTCHECKED
static name[33]
get_user_name(id, name, 32)
copy(g_names[id], 32, name)
}
}
public client_disconnect(id)
{
if(id != 0)
{
checked[id] = NU_NOTCHECKED
copy(g_names[id], 32, "")
}
}
stock tag_add(id, name[])
{
if ( !equali ( name, "[NO-UCP] ", 9 ) ) // Тега нет :/
{
format ( name, 31, "[NO-UCP] %s", name )
//force_rename(id, name)
set_task(0.5, "force_rename", TASK_ID + id, name, 31)
}
}
stock tag_del(id, name[])
{
if ( equali ( name, "[NO-UCP] ", 9 ) ) // Тег есть, но зачем?
{
replace ( name, 31, "[NO-UCP] ", "" )
trim ( name )
if (name[0] == EOS) copy(name, 7, "Player")
//force_rename(id, name)
set_task(0.5, "force_rename", TASK_ID + id, name, 31)
}
}
public force_rename(name[], id)//id, name[]
{
id -= TASK_ID
if ( !is_user_connected(id) ) return 0
engfunc(EngFunc_SetClientKeyValue, id, engfunc( EngFunc_GetInfoKeyBuffer, id ), "name", name)
client_cmd(id, "name ^"%s^"; setinfo name ^"%s^"", name, name)
return 0
}
stock search_name(name[])
{
new i = 1
for(; i<33; i++)
{
if( equal( name, g_names[i] ) ) return i
}
return 0
}
public native_has_user_ucp(plugin_id, param_count)
{
if(param_count != 1) return 0
new id = get_param(1)
return (checked[id] == NU_HASUCP)
}
public KickIgnore(id, level, cid)
{
return PLUGIN_HANDLED
}
forward amx_logged(plugin[], msg[]);
public amx_logged(plugin[], msg[])
{
new index
new name_len
static logged_name[33]
new ignore
if(equali(plugin,"ucp.amxx",8))
{
if(equali(msg,"Login: ",7))
{
// TODO: regex
name_len = copyc(logged_name, 32, msg[7], '|')
copy(logged_name, name_len-1, logged_name)
index = search_name(logged_name)
if( 0 == user_has_ucp(logged_name, index) )
shout_noucp_checked(index, 1)
} else
if(equali(msg,"Login NO-UCP: <",15))
{
if(regex_match_c(msg,compiledPattern,ignore) > 0)
{
regex_substr(compiledPattern,1,logged_name,32)
index = search_name(logged_name)
if( 0 == user_has_no_ucp(logged_name, index) )
shout_noucp_checked(index, 0)
} else {
log_amx("[ERROR] Name not found in: %s", msg)
}
}
}
return PLUGIN_HANDLED
}
stock shout_noucp_checked(index, result)
{
new iForward = CreateMultiForward("noucp_checked",ET_IGNORE, FP_CELL, FP_CELL),iReturn
if(iForward < 0)
return log_amx("Forward could not be created.")
if(!ExecuteForward(iForward,iReturn, index, result))
return log_amx("Could not execute forward.")
return DestroyForward(iForward)
}
stock user_has_ucp(logged_name[], index)
{
if(index == 0)
{
log_amx("[ERROR] Player not found [%s] %d (ucp)", logged_name, index)
return -1
}
new userid = get_user_userid(index)
static authid[33]
get_user_authid(index, authid, 127)
if ( _debug ) log_amx("UCP login: %s id=%d userid=%d steamid=%s", logged_name, index, userid, authid)
checked[index] = NU_HASUCP
return 0
}
stock user_has_no_ucp(logged_name[], index)
{
if(index == 0)
{
log_amx("[ERROR] Player not found [%s] %d (no ucp)", logged_name, index)
return -1
}
checked[index] = NU_CHECKED
new userid = get_user_userid(index)
#if defined TAG_EVERYONE
tag_add(userid, logged_name)
return 0
#else
#if defined ACCEPT_ADMIN
if(access(index, PROTECTED_ADMIN))
{
if ( _debug ) log_amx("Admin login: %s id=%d userid=%d", logged_name, index, userid)
return 0
}
#endif
#if defined ACCEPT_USER
if(access(index, PROTECTED_USER))
{
if ( _debug ) log_amx("s-Access login: %s id=%d userid=%d", logged_name, index, userid)
return 0
}
#endif
#if defined ACCEPT_STEAM
static authid[33]
get_user_authid(index, authid, 127)
#else
#if defined ACCEPT_REVEMU
static authid[33]
get_user_authid(index, authid, 127)
#endif
#endif
#if defined ACCEPT_STEAM
if(equali(authid,"STEAM_0:",8))
{
if ( _debug ) log_amx("Steam login: %s id=%d userid=%d steamid=%s", logged_name, index, userid, authid)
return 0
}
#endif
#if defined ACCEPT_REVEMU
if(equali(authid,"VALVE_0:",8))
{
if ( _debug ) log_amx("RevEmu login: %s id=%d userid=%d steamid=%s", logged_name, index, userid, authid)
return 0
}
#endif
#if defined ACCEPT_SUBNET
if(check_network(index) == SUBNET_REVERSE)
{
if ( _debug ) log_amx("Allowed subnet login: %s id=%d userid=%d steamid=%s", logged_name, index, userid, authid)
return 0
}
if ( _debug ) log_amx("Blocked subnet: %s id=%d userid=%d steamid=%s", logged_name, index, userid, authid)
#endif
server_cmd("kick #%d %s", userid, KickReason)
// Don't use server_exec here, or it will crash
return -1
#endif
}
#if defined ACCEPT_SUBNET
stock bool:check_network(index)
{
if(g_network_num == 0) return false
static ip[16], network[32]
new i, bool:result
get_user_ip(index, ip, 15, 0)
for(; i<g_network_num; i++)
{
format(network, 31, "%a", ArrayGetStringHandle(g_networks, i))
result = in_range(network, ip)
if (result) return true
}
return false
}
stock read_networks()
{
if ( !file_exists(DeniedFile) ) return 0
if ( file_size(DeniedFile, 0) < 9 ) return 0
new lineno, line[32], len
while (read_file(DeniedFile, lineno++, line, 31, len)) {
if ( len < 9 || line[0] == ';' )
continue
trim( line )
ArrayPushString(g_networks, line)
g_network_num++
}
return g_network_num
}
#endif
#if defined TAG_EVERYONE
public client_infochanged ( id ) // By Makzz
{
static sName[32]
if ( checked[id] == NU_CHECKED ) // Нет клиента
{
get_user_info ( id, "name", sName, 31 )
tag_add(id, sName)
}
else if ( checked[id] == NU_HASUCP ) // Есть клиент
{
get_user_info ( id, "name", sName, 31 )
tag_del(id,sName)
}
}
#endif