AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   Limitting Perm Ban Rights - SourceBans (https://forums.alliedmods.net/showthread.php?t=74458)

blik 07-19-2008 08:00

Limitting Perm Ban Rights - SourceBans
 
2 Attachment(s)
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.

bl4nk 07-19-2008 12:02

Re: Limitting Perm Ban Rights - SourceBans
 
..or you could use my TempBan plugin and use overrides to give it to them. :P

DJ Tsunami 07-19-2008 15:22

Re: Limitting Perm Ban Rights - SourceBans
 
How does that stop them from having access to permanent banning? :o

blik 07-19-2008 18:27

Re: Limitting Perm Ban Rights - SourceBans
 
Quote:

Originally Posted by DJ Tsunami (Post 655176)
How does that stop them from having access to permanent banning? :o

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?

DJ Tsunami 07-19-2008 21:02

Re: Limitting Perm Ban Rights - SourceBans
 
No, I was talking to bl4nk :wink:

bl4nk 07-19-2008 21:23

Re: Limitting Perm Ban Rights - SourceBans
 
Don't give them access to sm_ban?

DJ Tsunami 07-20-2008 07:35

Re: Limitting Perm Ban Rights - SourceBans
 
Meh, that means they can only temp ban. Not perfect, but I guess it works.

Lebson506th 07-20-2008 13:09

Re: Limitting Perm Ban Rights - SourceBans
 
In my opinion this should be built into sourcemod to begin with.

bl4nk 07-20-2008 13:16

Re: Limitting Perm Ban Rights - SourceBans
 
Quote:

Originally Posted by DJ Tsunami (Post 655462)
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.

DJ Tsunami 07-20-2008 13:42

Re: Limitting Perm Ban Rights - SourceBans
 
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 :wink:

bl4nk 07-20-2008 13:51

Re: Limitting Perm Ban Rights - SourceBans
 
Um, you do know that temporary bans are broken without a plugin to actually handle them, right? Try banning somebody for 1 minute, and wait 5. They won't be unbanned. Temporary bans stick until the server restarts or the player is manually unbanned. It's one of the many flaws of Valve's ban system.

blik 07-20-2008 14:11

Re: Limitting Perm Ban Rights - SourceBans
 
Quote:

Originally Posted by bl4nk (Post 655609)
Um, you do know that temporary bans are broken without a plugin to actually handle them, right? Try banning somebody for 1 minute, and wait 5. They won't be unbanned. Temporary bans stick until the server restarts or the player is manually unbanned. It's one of the many flaws of Valve's ban system.

I haven't noticed this behaviour on my servers. I have banned people for a day, and after the day ban expires, without restarting the server I have seen them back on playing.

DJ Tsunami 07-20-2008 14:49

Re: Limitting Perm Ban Rights - SourceBans
 
That's because you're using SourceBans, its ban system is way different than the default one in SRCDS.

bl4nk 07-20-2008 15:58

Re: Limitting Perm Ban Rights - SourceBans
 
Oh.. I completely overlooked the "SourceBans" part of the thread title. :?

NightLinks 09-02-2008 03:39

Re: Limitting Perm Ban Rights - SourceBans
 
Somethings wrong the file does not want to compile. :(

blik 09-02-2008 15:56

Re: Limitting Perm Ban Rights - SourceBans
 
Quote:

Originally Posted by NightLinks (Post 679885)
Somethings wrong the file does not want to compile. :(

You probably didnt put the sourcebans include in the include folder when compiling.

I've attached the source and a compiled version for the latest version of the sourcebans plugin. See initial post attachments...

Ommand 09-19-2008 14:02

Re: Limitting Perm Ban Rights - SourceBans
 
Hey I tried using your version of sourcebans but anyone with the d flag is still able to permaban players, am I doing something wrong? I don't need to add an override or anything do I?

Using Sourcemod 1.1.0.2500 in a DoD:S server.

Edit: Nevermind, I expected there to be a difference between upper and lower case flags.

blik 09-21-2008 04:17

Re: Limitting Perm Ban Rights - SourceBans
 
The modification I made removes perm ban rights for all flags except O. It doesn't do anything with d flag.

ph 02-25-2009 22:31

Re: Limitting Perm Ban Rights - SourceBans
 
Can this be re-coded/ updated to incorporate version 1.4.1

blik 02-27-2009 13:18

Re: Limitting Perm Ban Rights - SourceBans
 
SB has already implemented this in a sort of fashion. If you give unban priv you give perm ban. This is e flag btw.


All times are GMT -4. The time now is 18:52.

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