Dar vienas klausimas del amx_ban
Posted: 2013 Jan 25 17:10
Dar viena klausima turiu del amx_ban. Kaip pasidaryti, kad galima butu duoti ban ir per IP. Bandziau ir per amx_banip tas pats.


Tai kaip padaryti kad rasytu i banned.cfg gi anksciau rasydavo ten.xedga wrote:Nes amxbans į duombazę įrašo banus, ne i faila.
Isirasiau toki plugina ( unbanmenu.amxx ) parasius amx_unbanmenu islenda IP arba ID anksciau budavo ten pora Ipu, dabar tiems kam daves banus neisiraso ten.aaarnas wrote:Į banned.cfg įrašoma tik tuo metu, jei yra kažkokių banų pačiame serveryje ir serveris yra išjungiamas. Kitu atveju jame niekada nieko nerasi.
Code: Select all
/* Plugin generated by AMXX-Studio */ #include <amxmodx>#include <amxmisc> new g_menuPosition[33]new g_menuSelect[33][64]new g_menuUnBanType[33]new g_menuUnBanLine[33][2]new g_menuUnBanText[33][8][32]new g_bannedCfgFile[2][] = {"banned.cfg","listip.cfg"}new g_coloredMenus public plugin_init() { register_plugin("UnBanmenu", "1", "AMX Team") register_clcmd("amx_unbanmenu","cmdUnBanMenu", ADMIN_BAN, "- displays unban menu") register_menucmd(register_menuid("UnBan STEAMID or IP?"),(1<<0|1<<1|1<<9),"actionUnBanMenuType") register_menucmd(register_menuid("UnBan Menu"),1023,"actionUnBanMenu") g_coloredMenus = colored_menus()}public actionUnBanMenu(id,key) { switch(key) { case 8: { displayUnBanMenu(id, ++g_menuPosition[id]) } case 9: { g_menuUnBanLine[id][0] = g_menuUnBanLine[id][0] - (8 + g_menuUnBanLine[id][1]) if(g_menuUnBanLine[id][0] < 0) g_menuUnBanLine[id][0] = 0 displayUnBanMenu(id, --g_menuPosition[id]) } default: { new name[32], authid[32], ipaddress[24] get_user_authid(id, authid, 31) get_user_name(id, name, 31) get_user_ip(id, ipaddress, 23, 1) log_amx("UnBan: ^"%s<%d><%s><%s>^" unban ^"%s^"", name,get_user_userid(id),authid,ipaddress,g_menuUnBanText[id][key]) switch (get_cvar_num("amx_show_activity")) { case 2: client_print(0, print_chat, "ADMIN %s: unban %s", name, g_menuUnBanText[id][key]) case 1: client_print(0, print_chat, "ADMIN: unban %s", g_menuUnBanText[id][key]) } if(g_menuUnBanType[id] == 1) { server_cmd("removeip ^"%s^"; writeip", g_menuUnBanText[id][key]) server_exec() console_print(id, "IP ^"%s^" removed from ban list", g_menuUnBanText[id][key]) } else { server_cmd("removeid %s; writeid", g_menuUnBanText[id][key]) console_print(id, "Authid ^"%s^" removed from ban list", g_menuUnBanText[id][key]) } g_menuUnBanLine[id][0] = g_menuUnBanLine[id][1] = 0 displayUnBanMenu(id, g_menuPosition[id] = 0) } } return PLUGIN_HANDLED} checkSTEAMID(steamid[]) { new len = strlen(steamid) if(len > 10 && equali(steamid, "STEAM_", 6) && steamid[7] == ':' && steamid[9] == ':' && str_to_num(steamid[10])) { return 1 } return 0} checkIP(ip[]) { new len = strlen(ip) new dots = 0, i = 0 while(isdigit(ip[i]) || ip[i]=='.') if(ip[i++] == '.') ++dots if(i == len && dots == 3) { return 1 } return 0} displayUnBanMenu(id,pos) { if(pos < 0) return new menuBody[512] new b = 0 new len = format(menuBody, 511, g_coloredMenus ? "\yUnBan Menu\R%d^n\w^n" : "UnBan Menu %d^n^n", id, "UNBAN_MENU", pos + 1) new keys = (1<<9) new textlen, line new type = g_menuUnBanType[id] new temp[32], banTime[32], disable if(file_exists(g_bannedCfgFile[type])) { line = g_menuUnBanLine[id][0] while((line = read_file(g_bannedCfgFile[type], line, g_menuSelect[id], 63, textlen))) { temp[0] = '^0' banTime[0] = '^0' g_menuUnBanText[id][b][0] = '^0' disable = 0 if(textlen < 9) disable = 1 else if(parse(g_menuSelect[id], temp, 31, banTime, 31, g_menuUnBanText[id][b], 31) != 3) disable = 1 else if((type == 1 && !checkIP(g_menuUnBanText[id][b])) || (type == 0 && !checkSTEAMID(g_menuUnBanText[id][b]))) disable = 1 if(disable == 0) { keys |= (1<<b) if(g_coloredMenus) len += format(menuBody[len], 511-len, "%d. %s\R\r%s^n\w", b, g_menuUnBanText[id][b++], banTime) else len += format(menuBody[len], 511-len, "%d. %s ( %s )^n", b, g_menuUnBanText[id][b++], banTime) } else { if(g_coloredMenus) len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, g_menuUnBanText[id][b++]) else len += format(menuBody[len], 511-len, "#. %s^n", b, g_menuUnBanText[id][b++]) } if(b == 8) break } if(b == 8 && read_file(g_bannedCfgFile[type], line, g_menuSelect[id], 63, textlen) > 0) { format(menuBody[len], 511-len, "^n9. More...^n0. %s",id, pos ? "Back" : "Exit",id) keys |= (1<<8) } else format(menuBody[len], 511-len, "^n0. %s", pos ? "Back" : "Exit",id) g_menuUnBanLine[id][1] = line - g_menuUnBanLine[id][0] g_menuUnBanLine[id][0] = line show_menu(id, keys, menuBody, -1, "UnBan Menu") } return} public actionUnBanMenuType(id,key) { switch(key) { case 9: return PLUGIN_HANDLED default: { g_menuUnBanType[id] = key // 0 = STEAMID, 1 = IP g_menuUnBanLine[id][0] = g_menuUnBanLine[id][1] = 0 displayUnBanMenu(id, g_menuPosition[id] = 0) } } return PLUGIN_HANDLED} displayUnBanMenuType(id) { new menuBody[512] new len = format(menuBody, 511, g_coloredMenus ? "\yUnBan STEAMID or IP?^n\w^n" :"UnBan STEAMID or IP?^n^n",id) new keys = (1<<0)|(1<<1)|(1<<9) len += format(menuBody[len], 511-len, "1. STEAMID^n",id) len += format(menuBody[len], 511-len, "2. IP^n",id) format(menuBody[len], 511-len, "^n0. Exit",id) show_menu(id, keys, menuBody, -1, "UnBan STEAMID or IP?")} public cmdUnBanMenu(id,level,cid) { if(!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED g_menuUnBanType[id] = -1 displayUnBanMenuType(id) return PLUGIN_HANDLED}
Code: Select all
new g_bannedCfgFile[2][] = {"banned.cfg","listip.cfg"}