Raised This Month: $51 Target: $400
 12% 

help unbanmenu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Noam
Member
Join Date: Jun 2019
Old 07-31-2019 , 03:42   help unbanmenu
Reply With Quote #1

Code:
/* 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
}
does anyone know why its shows only permanenet bans at unban list?
+ and when someone has flag "a" its does'nt showing him too.

Last edited by Noam; 07-31-2019 at 03:51.
Noam is offline
tarsisd2
Veteran Member
Join Date: Feb 2016
Location: brazil
Old 07-31-2019 , 03:51   Re: help unbanmenu
Reply With Quote #2

Because it only saves permanent bans on file, temporary bans are saved in memory and i think its cleared by stoping/restarting the server
tarsisd2 is offline
Noam
Member
Join Date: Jun 2019
Old 07-31-2019 , 04:59   Re: help unbanmenu
Reply With Quote #3

how can i fix it to show all bans?
Noam is offline
tarsisd2
Veteran Member
Join Date: Feb 2016
Location: brazil
Old 07-31-2019 , 05:53   Re: help unbanmenu
Reply With Quote #4

Quote:
Originally Posted by Noam View Post
how can i fix it to show all bans?
Not really possible as far as i know, it doesn't save in any files and its removed on server restart, like if you ban someone for 2 weeks and your servers is restarted, they will be back at your server, and you can't see players names, i use advanced bans, it saves all the players details, even temp bans, ans you can see all the info from banned players on file or typing amx_banlist, so there is no need for a unban menu
tarsisd2 is offline
Noam
Member
Join Date: Jun 2019
Old 07-31-2019 , 06:34   Re: help unbanmenu
Reply With Quote #5

Quote:
Originally Posted by tarsisd2 View Post
Not really possible as far as i know, it doesn't save in any files and its removed on server restart, like if you ban someone for 2 weeks and your servers is restarted, they will be back at your server, and you can't see players names, i use advanced bans, it saves all the players details, even temp bans, ans you can see all the info from banned players on file or typing amx_banlist, so there is no need for a unban menu
yeah im using advanced bans too, but i need unban in menu instead of amx_unban "steamid"
Noam is offline
Alber9091
Veteran Member
Join Date: Jun 2014
Location: Karachi, Pakistan
Old 07-31-2019 , 06:42   Re: help unbanmenu
Reply With Quote #6

If you can change your ban system, then you can use this ban system and enjoy all those features which you want:

https://dev-cs.ru/resources/196/

Fresh Bans
Alber9091 is offline
tarsisd2
Veteran Member
Join Date: Feb 2016
Location: brazil
Old 07-31-2019 , 07:19   Re: help unbanmenu
Reply With Quote #7

Quote:
Originally Posted by Alber9091 View Post
If you can change your ban system, then you can use this ban system and enjoy all those features which you want:

https://dev-cs.ru/resources/196/

Fresh Bans
Its better to use advanced bans, those web based ban system are too complicated for some people, need hosting + mysql, i doubt he will use it
tarsisd2 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-03-2019 , 13:58   Re: help unbanmenu
Reply With Quote #8

Use this. It has an 'unban' menu where all bans are stored, and you can easily remove bans from the menu.
__________________

Last edited by edon1337; 08-03-2019 at 14:02.
edon1337 is offline
tarsisd2
Veteran Member
Join Date: Feb 2016
Location: brazil
Old 08-03-2019 , 17:32   Re: help unbanmenu
Reply With Quote #9

Quote:
Originally Posted by edon1337 View Post
Use this. It has an 'unban' menu where all bans are stored, and you can easily remove bans from the menu.
Yes, i was thinking about this, i will start using you plugin on my server too, the advanced bans its a bit outdated
tarsisd2 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-03-2019 , 18:15   Re: help unbanmenu
Reply With Quote #10

Quote:
Originally Posted by tarsisd2 View Post
Yes, i was thinking about this, i will start using you plugin on my server too, the advanced bans its a bit outdated
I need to implement that max bans per day from Advanced Bans in my system but I got some other stuff to do.
__________________

Last edited by edon1337; 08-03-2019 at 18:16.
edon1337 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:07.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode