Raised This Month: $ Target: $400
 0% 

Limitting Perm Ban Rights - SourceBans


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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