Raised This Month: $ Target: $400
 0% 

Limitting Perm Ban Rights - SourceBans


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
blik
Senior Member
Join Date: May 2006
Old 07-19-2008 , 08:00   Limitting Perm Ban Rights - SourceBans
Reply With Quote #1

Posting this as I'm sure many people who are moving from mani will miss the ability to only give perm ban rights to certain admins.

This is my first time editting a sourcemod plugin, I am a noob with sourcemod. So don't all give me a hard time if It can be improved.

This will grant perm ban rights to admins with the O flag if you look at the changes, you'll see it's simple to change it to a different Admin_Custom if you prefer.

First change:

Find DisplayBanTimeMenu(client) procedure, as shown below:
Code:
DisplayBanTimeMenu(client)
{
	if(IsPluginDebugging(pluginHandle))
			LogToFile(logFile, "DisplayBanTimeMenu()");
		
	new Handle:menu = CreateMenu(MenuHandler_BanTimeList);
	
	decl String:title[100];
	//Format(title, sizeof(title), "%T:", "Ban player", client);
	Format(title, sizeof(title), "Ban player", client);
	SetMenuTitle(menu, title);
	SetMenuExitBackButton(menu, true);

	AddMenuItem(menu, "0", "Permanent");
	AddMenuItem(menu, "10", "10 Minutes");
	AddMenuItem(menu, "30", "30 Minutes");
	AddMenuItem(menu, "60", "1 Hour");
	AddMenuItem(menu, "240", "4 Hours");
	AddMenuItem(menu, "1440", "1 Day");
	AddMenuItem(menu, "10080", "1 Week");
	
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}
Replace with:

Code:
DisplayBanTimeMenu(client)
{
	decl String:adminSteam[64];
	GetClientAuthString(client, adminSteam, sizeof(adminSteam));
	new AdminId:aid = FindAdminByIdentity(AUTHMETHOD_STEAM, adminSteam);
	new bool:hasPermBan = false;
	
	if(IsPluginDebugging(pluginHandle))
			LogToFile(logFile, "DisplayBanTimeMenu()");
		
	new Handle:menu = CreateMenu(MenuHandler_BanTimeList);
	
	decl String:title[100];
	//Format(title, sizeof(title), "%T:", "Ban player", client);
	Format(title, sizeof(title), "Ban player", client);
	SetMenuTitle(menu, title);
	SetMenuExitBackButton(menu, true);
	hasPermBan = GetAdminFlag(aid, Admin_Custom1);
	if (hasPermBan)
	{

		AddMenuItem(menu, "0", "Permanent");
	}
	AddMenuItem(menu, "10", "10 Minutes");
	AddMenuItem(menu, "30", "30 Minutes");
	AddMenuItem(menu, "60", "1 Hour");
	AddMenuItem(menu, "240", "4 Hours");
	AddMenuItem(menu, "1440", "1 Day");
	AddMenuItem(menu, "10080", "1 Week");
	
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
}
That will only show the perm ban option to admins with O flag in the menu. Next we need to stop perm bans from console.

Find public Action:CommandBan(client, args), should look like this:
Code:
public Action:CommandBan(client, args)
{
	if(args < 2)
	{
		ReplyToCommand(client, "Usage: sm_ban <#userid|name> <time|0> [reason]");
		return Plugin_Handled;
	}

	// This is mainly for me sanity since client used to be called admin and target used to be called client
	new admin = client;
	
	// Get the target, find target returns a message on failure so we do not
	decl String:buffer[100];
	GetCmdArg(1, buffer, sizeof(buffer));
	new target = FindTarget(client, buffer, true);
	if(target == -1)
	{
		return Plugin_Handled;
	}

	// Get the ban time
	GetCmdArg(2, buffer, sizeof(buffer));
	new time = StringToInt(buffer);

	// Get the reason
	new String:reason[40];
	if(args >= 3)
	{
		GetCmdArg(3, reason, sizeof(reason));
	}

	if(!PlayerStatus[target])
	{
		// The target has not been banned verify. It must be completed before you can ban anyone.
		ReplyToCommand(admin, "%c[%cSourceBans%c]%c %t", GREEN, NAMECOLOR, GREEN, NAMECOLOR, "Ban Not Verified");
		return Plugin_Handled;
	}

	CreateBan(client, target, time, reason);
	return Plugin_Handled;
}
Replace with
Code:
public Action:CommandBan(client, args)
{
	if(args < 2)
	{
		ReplyToCommand(client, "Usage: sm_ban <#userid|name> <time|0> [reason]");
		return Plugin_Handled;
	}

	// This is mainly for me sanity since client used to be called admin and target used to be called client
	new admin = client;
	
	// Get the target, find target returns a message on failure so we do not
	decl String:buffer[100];
	GetCmdArg(1, buffer, sizeof(buffer));
	new target = FindTarget(client, buffer, true);
	if(target == -1)
	{
		return Plugin_Handled;
	}

	// Get the ban time
	GetCmdArg(2, buffer, sizeof(buffer));
	new time = StringToInt(buffer);

	// Get the reason
	new String:reason[40];
	if(args >= 3)
	{
		GetCmdArg(3, reason, sizeof(reason));
	}

	if(!PlayerStatus[target])
	{
		// The target has not been banned verify. It must be completed before you can ban anyone.
		ReplyToCommand(admin, "%c[%cSourceBans%c]%c %t", GREEN, NAMECOLOR, GREEN, NAMECOLOR, "Ban Not Verified");
		return Plugin_Handled;
	}
	
	decl String:adminSteam[64];
	GetClientAuthString(client, adminSteam, sizeof(adminSteam));
	new AdminId:aid = FindAdminByIdentity(AUTHMETHOD_STEAM, adminSteam);
	new bool:hasPermBan = false;
	hasPermBan = GetAdminFlag(aid, Admin_Custom1);
	
	if((hasPermBan == false) && (time == 0))
	{
		ReplyToCommand(admin, "You do not have Perm Ban Permission");
		return Plugin_Handled;
	}
	
	CreateBan(client, target, time, reason);
	return Plugin_Handled;
}
I've attached the code too, but it will fail to compile through the website since it needs the sourcebans include.

Hope this helps

Edit: Updated attached source with latest version of the plugin. Also included compiled version.
Attached Files
File Type: sp Get Plugin or Get Source (sourcebans.sp - 439 views - 64.2 KB)
File Type: smx sourcebans.smx (25.5 KB, 404 views)

Last edited by blik; 09-02-2008 at 15:55.
blik is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 07-19-2008 , 12:02   Re: Limitting Perm Ban Rights - SourceBans
Reply With Quote #2

..or you could use my TempBan plugin and use overrides to give it to them.
bl4nk is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 07-19-2008 , 15:22   Re: Limitting Perm Ban Rights - SourceBans
Reply With Quote #3

How does that stop them from having access to permanent banning?
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
blik
Senior Member
Join Date: May 2006
Old 07-19-2008 , 18:27   Re: Limitting Perm Ban Rights - SourceBans
Reply With Quote #4

Quote:
Originally Posted by DJ Tsunami View Post
How does that stop them from having access to permanent banning?
First change simply removes the option from the menu if Admin_Custom1 is false, second stops the sm_ban command with time 0

Code:
hasPermBan = GetAdminFlag(aid, Admin_Custom1);
	
	if((hasPermBan == false) && (time == 0))
	{
		ReplyToCommand(admin, "You do not have Perm Ban Permission");
		return Plugin_Handled;
	}
I've tested it and it works, but as I said im new to sourcemod, so maybe you see something I overlooked?
blik is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 07-19-2008 , 21:02   Re: Limitting Perm Ban Rights - SourceBans
Reply With Quote #5

No, I was talking to bl4nk
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 07-19-2008 , 21:23   Re: Limitting Perm Ban Rights - SourceBans
Reply With Quote #6

Don't give them access to sm_ban?
bl4nk is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 07-20-2008 , 07:35   Re: Limitting Perm Ban Rights - SourceBans
Reply With Quote #7

Meh, that means they can only temp ban. Not perfect, but I guess it works.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 07-20-2008 , 13:16   Re: Limitting Perm Ban Rights - SourceBans
Reply With Quote #8

Quote:
Originally Posted by DJ Tsunami View Post
Meh, that means they can only temp ban. Not perfect, but I guess it works.
I think that's the purpose of this thread. To make certain players not be able to permanenly ban others.
bl4nk is offline
Lebson506th
Veteran Member
Join Date: Jul 2008
Old 07-20-2008 , 13:09   Re: Limitting Perm Ban Rights - SourceBans
Reply With Quote #9

In my opinion this should be built into sourcemod to begin with.
Lebson506th is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 07-20-2008 , 13:42   Re: Limitting Perm Ban Rights - SourceBans
Reply With Quote #10

Yes, but your plugin only allows certain admins to ban people until the map changes, unlike blik's plugin, which lets admins ban for x minutes, but not permanently. So yeah, matter of preference
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
Reply


Thread Tools
Display Modes

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 18:52.


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