Raised This Month: $ Target: $400
 0% 

Ban duration if not specified when using sm_ban


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Noobtastic
Member
Join Date: Nov 2007
Old 12-20-2007 , 07:15   Ban duration if not specified when using sm_ban
Reply With Quote #1

Hey everybody,

I've been trying to find out how to put a restriction on sm_ban. We use SourceBans to maintain a global ban list across all our servers, and we don't want members/admins banning people for more than one day.

Of course, I can just tell them to only ban people using 'sm_ban name 1440', but that is bound to go wrong . So I was wondering if it is possible to change the default ban duration of sm_ban, when no duration is specified. So instead of making it a permanent ban, it should be a one day ban when using 'sm_ban name'.

I've been trying to figure out the basebans.sp source file, but it's way too complicated for me, so I'm hoping to get some help here .

Thanks in advance for taking the time to reply .

Noobtastic
Noobtastic is offline
ferret
SourceMod Developer
Join Date: Dec 2004
Location: Atlanta, GA
Old 12-20-2007 , 07:36   Re: Ban duration if not specified when using sm_ban
Reply With Quote #2

SourceBans doesn't use basebans.sp. As soon as SourceBans loads, it forces basebans to unload so that it can replace the commands with its own copies. At least, it USED to do that, I might be out of date.

Either way. There's the easy way and the slightly harder way.

#1) sm_ban ALWAYS limits to 1440
#2) sm_ban limits to 1440 except for ROOT admins.

#1 is easy, you simply add this to sm_ban (Either basebans or sourcebans copy. Note this is pseudo code, not real code)

Code:
if (time > 1440 || time < 1)
{
     time = 1440;
}
Basicly with this, if they put 0 (Permanent) or larger than 1440, it gets reset to 1440. If you wanted to be fancy, you could make it a cvar instead of a hardcoded 1440, and you could also exclude root users.

I believe there's a feature request to add this to the base sm_ban, but SourceBans would have to implement it seperately.
__________________
I'm a blast from the past!
ferret is offline
Noobtastic
Member
Join Date: Nov 2007
Old 12-20-2007 , 07:58   Re: Ban duration if not specified when using sm_ban
Reply With Quote #3

Thanks for the quick reply once again ferret, I'll look into your suggestions later today .

Edit: I'm such a noob, I didn't even realize SourceBans replaced the basebans plugin. That's what you get for simply copy&pasting the plugin from a server you didn't set up yourself ;). I'll go see if I can manage to use the pseudo code you gave me with my incredibly limited scripting skills .

Last edited by Noobtastic; 12-20-2007 at 08:18.
Noobtastic is offline
KALASH NICOLE
Member
Join Date: Feb 2016
Old 06-18-2017 , 05:15   Re: Ban duration if not specified when using sm_ban
Reply With Quote #4

hello, i tried to add what ferret suggested into basebans.sp ( i edited it so whatever the ban duration selected by an admin it will enforce a 60 minutes ban.

PHP Code:
public Action Command_BanIp(int clientint args)
{
    if (
args 2)
    {
        
ReplyToCommand(client"[SM] Usage: sm_banip <ip|#userid|name> <time> [reason]");
        return 
Plugin_Handled;
    }

    
int lennext_len;
    
char Arguments[256];
    
char arg[50], time[20];
    
    
GetCmdArgString(Argumentssizeof(Arguments));
    
len BreakString(Argumentsargsizeof(arg));

    
    
    if ((
next_len BreakString(Arguments[len], timesizeof(time))) != -1)
    {
        
len += next_len;
    }
    else
    {
        
len 0;
        
Arguments[0] = '\0';
    }

    if (
StrEqual(arg"0"))
    {
        
ReplyToCommand(client"[SM] %t""Cannot ban that IP");
        return 
Plugin_Handled;
    }
    
    
char target_name[MAX_TARGET_LENGTH];
    
int target_list[1];
    
bool tn_is_ml;
    
int found_client = -1;
    
    if (
ProcessTargetString(
            
arg,
            
client
            
target_list
            
1
            
COMMAND_FILTER_CONNECTED|COMMAND_FILTER_NO_MULTI,
            
target_name,
            
sizeof(target_name),
            
tn_is_ml) > 0)
    {
        
found_client target_list[0];
    }
    
    
bool has_rcon;
    
    if (
client == || (client == && !IsDedicatedServer()))
    {
        
has_rcon true;
    }
    else
    {
        
AdminId id GetUserAdmin(client);
        
has_rcon = (id == INVALID_ADMIN_ID) ? false GetAdminFlag(idAdmin_RCON);
    }
    
    
int hit_client = -1;
    if (
found_client != -1
        
&& !IsFakeClient(found_client)
        && (
has_rcon || CanUserTarget(clientfound_client)))
    {
        
GetClientIP(found_clientargsizeof(arg));
        
hit_client found_client;
    }
    
    if (
hit_client == -&& !has_rcon)
    {
        
ReplyToCommand(client"[SM] %t""No Access");
        return 
Plugin_Handled;
    }

    
int minutes StringToInt(time);

    
LogAction(client
              
hit_client
              
"\"%L\" added ban (minutes \"%d\") (ip \"%s\") (reason \"%s\")"
              
client
              
minutes
              
arg
              
Arguments[len]);
                
    
ReplyToCommand(client"[SM] %t""Ban added");
    
    
BanIdentity(arg
                
minutes
                
BANFLAG_IP
                
Arguments[len], 
                
"sm_banip"
                
client);
                
    if (
hit_client != -1)
    {
        
KickClient(hit_client"Banned: %s for 60 minutes"Arguments[len]);
    }
    
    if (
time || time 1)
    {
     
time 60;
    }

    return 
Plugin_Handled;

but i got these compile errors :

//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// basebans.sp
//
// C:\Program Files (x86)\Steam\SteamApps\common\insurgency2\insu rgency\addons\s
ourcemod\scripting\basebans.sp(253) : warning 217: loose indentation
// C:\Program Files (x86)\Steam\SteamApps\common\insurgency2\insu rgency\addons\s
ourcemod\scripting\basebans.sp(253) : error 033: array must be indexed (variable
"time")
// C:\Program Files (x86)\Steam\SteamApps\common\insurgency2\insu rgency\addons\s
ourcemod\scripting\basebans.sp(255) : error 033: array must be indexed (variable
"time")
// C:\Program Files (x86)\Steam\SteamApps\common\insurgency2\insu rgency\addons\s
ourcemod\scripting\basebans.sp(25 : warning 217: loose indentation
//
// 2 Errors.
//
// Compilation Time: 0,22 sec
// ----------------------------------------

Last edited by KALASH NICOLE; 06-18-2017 at 05:17.
KALASH NICOLE is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 06-18-2017 , 08:17   Re: Ban duration if not specified when using sm_ban
Reply With Quote #5

delete what you added
PHP Code:
    if (time || time 1)
    {
     
time 60;
    } 
and add

PHP Code:
    if (minute || minute 1)
    {
     
minute 60;
    } 
before BanIdentity
8guawong is offline
KALASH NICOLE
Member
Join Date: Feb 2016
Old 06-18-2017 , 10:10   Re: Ban duration if not specified when using sm_ban
Reply With Quote #6

thanks for reply.

i tried your solution :

i get this compile error :

//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// basebans.sp
//
// C:\Program Files (x86)\Steam\SteamApps\common\insurgency2\insu rgency\addons\s
ourcemod\scripting\basebans.sp(241) : error 017: undefined symbol "minute"
// C:\Program Files (x86)\Steam\SteamApps\common\insurgency2\insu rgency\addons\s
ourcemod\scripting\basebans.sp(243) : error 017: undefined symbol "minute"
// C:\Program Files (x86)\Steam\SteamApps\common\insurgency2\insu rgency\addons\s
ourcemod\scripting\basebans.sp(243) : warning 215: expression has no effect
//
// 2 Errors.
//
// Compilation Time: 0,34 sec
// ----------------------------------------

Press enter to exit ...
KALASH NICOLE is offline
KALASH NICOLE
Member
Join Date: Feb 2016
Old 06-30-2017 , 02:24   Re: Ban duration if not specified when using sm_ban
Reply With Quote #7

hmm. i tried with minutes instead of minute. the compile worked. I set 1 minute in the script (before BanIdentity).

if (minutes > 0 || minutes < 1)
{
minutes = 1;
}

but when i try to ban myself (sm_ban) for 2 minutes it keeps bannning me 2 entire minutes instead of 1 minute.

PHP Code:
/**
 * vim: set ts=4 :
 * =============================================================================
 * SourceMod Basic Commands Plugin
 * Implements basic admin commands.
 *
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
 * =============================================================================
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 3.0, as published by the
 * Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * As a special exception, AlliedModders LLC gives you permission to link the
 * code of this program (as well as its derivative works) to "Half-Life 2," the
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
 * by the Valve Corporation.  You must obey the GNU General Public License in
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
 * this exception to all derivative works.  AlliedModders LLC defines further
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
 * or <http://www.sourcemod.net/license.php>.
 *
 * Version: $Id$
 */

#pragma semicolon 1

#include <sourcemod>
#undef REQUIRE_PLUGIN
#include <adminmenu>

#pragma newdecls required

public Plugin myinfo =
{
    
name "Basic Ban Commands",
    
author "AlliedModders LLC",
    
description "Basic Banning Commands",
    
version SOURCEMOD_VERSION,
    
url "http://www.sourcemod.net/"
};

TopMenu hTopMenu;

int g_BanTarget[MAXPLAYERS+1];
int g_BanTargetUserId[MAXPLAYERS+1];
int g_BanTime[MAXPLAYERS+1];

bool g_IsWaitingForChatReason[MAXPLAYERS+1];
KeyValues g_hKvBanReasons;
char g_BanReasonsPath[PLATFORM_MAX_PATH];

#include "basebans/ban.sp"

public void OnPluginStart()
{
    
BuildPath(Path_SMg_BanReasonsPathsizeof(g_BanReasonsPath), "configs/banreasons.txt");

    
LoadBanReasons();

    
LoadTranslations("common.phrases");
    
LoadTranslations("basebans.phrases");
    
LoadTranslations("core.phrases");

    
RegAdminCmd("sm_ban"Command_BanADMFLAG_BAN"sm_ban <#userid|name> <minutes|0> [reason]");
    
RegAdminCmd("sm_unban"Command_UnbanADMFLAG_UNBAN"sm_unban <steamid|ip>");
    
RegAdminCmd("sm_addban"Command_AddBanADMFLAG_RCON"sm_addban <time> <steamid> [reason]");
    
RegAdminCmd("sm_banip"Command_BanIpADMFLAG_BAN"sm_banip <ip|#userid|name> <time> [reason]");
    
    
//This to manage custom ban reason messages
    
RegConsoleCmd("sm_abortban"Command_AbortBan"sm_abortban");
    
    
/* Account for late loading */
    
TopMenu topmenu;
    if (
LibraryExists("adminmenu") && ((topmenu GetAdminTopMenu()) != null))
    {
        
OnAdminMenuReady(topmenu);
    }
}

public 
void OnMapStart()
{
    
//(Re-)Load BanReasons
    
LoadBanReasons();
}

public 
void OnClientDisconnect(int client)
{
    
g_IsWaitingForChatReason[client] = false;
}

void LoadBanReasons()
{
    
delete g_hKvBanReasons;

    
g_hKvBanReasons = new KeyValues("banreasons");

    if (
g_hKvBanReasons.ImportFromFile(g_BanReasonsPath))
    {
        
char sectionName[255];
        if (!
g_hKvBanReasons.GetSectionName(sectionNamesizeof(sectionName)))
        {
            
SetFailState("Error in %s: File corrupt or in the wrong format"g_BanReasonsPath);
            return;
        }

        if (
strcmp(sectionName"banreasons") != 0)
        {
            
SetFailState("Error in %s: Couldn't find 'banreasons'"g_BanReasonsPath);
            return;
        }
        
        
//Reset kvHandle
        
g_hKvBanReasons.Rewind();
    } else {
        
SetFailState("Error in %s: File not found, corrupt or in the wrong format"g_BanReasonsPath);
        return;
    }
}

public 
void OnAdminMenuReady(Handle aTopMenu)
{
    
TopMenu topmenu TopMenu.FromHandle(aTopMenu);

    
/* Block us from being called twice */
    
if (topmenu == hTopMenu)
    {
        return;
    }
    
    
/* Save the Handle */
    
hTopMenu topmenu;
    
    
/* Find the "Player Commands" category */
    
TopMenuObject player_commands hTopMenu.FindCategory(ADMINMENU_PLAYERCOMMANDS);

    if (
player_commands != INVALID_TOPMENUOBJECT)
    {
        
hTopMenu.AddItem("sm_ban"AdminMenu_Banplayer_commands"sm_ban"ADMFLAG_BAN);
    }
}

public 
Action Command_BanIp(int clientint args)
{
    if (
args 2)
    {
        
ReplyToCommand(client"[SM] Usage: sm_banip <ip|#userid|name> <time> [reason]");
        return 
Plugin_Handled;
    }

    
int lennext_len;
    
char Arguments[256];
    
char arg[50], time[20];
    
    
GetCmdArgString(Argumentssizeof(Arguments));
    
len BreakString(Argumentsargsizeof(arg));
    
    if ((
next_len BreakString(Arguments[len], timesizeof(time))) != -1)
    {
        
len += next_len;
    }
    else
    {
        
len 0;
        
Arguments[0] = '\0';
    }

    if (
StrEqual(arg"0"))
    {
        
ReplyToCommand(client"[SM] %t""Cannot ban that IP");
        return 
Plugin_Handled;
    }
    
    
char target_name[MAX_TARGET_LENGTH];
    
int target_list[1];
    
bool tn_is_ml;
    
int found_client = -1;
    
    if (
ProcessTargetString(
            
arg,
            
client
            
target_list
            
1
            
COMMAND_FILTER_CONNECTED|COMMAND_FILTER_NO_MULTI,
            
target_name,
            
sizeof(target_name),
            
tn_is_ml) > 0)
    {
        
found_client target_list[0];
    }
    
    
bool has_rcon;
    
    if (
client == || (client == && !IsDedicatedServer()))
    {
        
has_rcon true;
    }
    else
    {
        
AdminId id GetUserAdmin(client);
        
has_rcon = (id == INVALID_ADMIN_ID) ? false GetAdminFlag(idAdmin_RCON);
    }
    
    
int hit_client = -1;
    if (
found_client != -1
        
&& !IsFakeClient(found_client)
        && (
has_rcon || CanUserTarget(clientfound_client)))
    {
        
GetClientIP(found_clientargsizeof(arg));
        
hit_client found_client;
    }
    
    if (
hit_client == -&& !has_rcon)
    {
        
ReplyToCommand(client"[SM] %t""No Access");
        return 
Plugin_Handled;
    }

    
int minutes StringToInt(time);

    
LogAction(client
              
hit_client
              
"\"%L\" added ban (minutes \"%d\") (ip \"%s\") (reason \"%s\")"
              
client
              
minutes
              
arg
              
Arguments[len]);
                
    
ReplyToCommand(client"[SM] %t""Ban added");

        if (
minutes || minutes 1)
        {
         
minutes 1;
        } 
    
    
BanIdentity(arg
                
minutes
                
BANFLAG_IP
                
Arguments[len], 
                
"sm_banip"
                
client);
                
    if (
hit_client != -1)
    {
        
KickClient(hit_client"Banned: %s"Arguments[len]);
    }

    return 
Plugin_Handled;
}

public 
Action Command_AddBan(int clientint args)
{
    if (
args 2)
    {
        
ReplyToCommand(client"[SM] Usage: sm_addban <time> <steamid> [reason]");
        return 
Plugin_Handled;
    }

    
char arg_string[256];
    
char time[50];
    
char authid[50];

    
GetCmdArgString(arg_stringsizeof(arg_string));

    
int lentotal_len;

    
/* Get time */
    
if ((len BreakString(arg_stringtimesizeof(time))) == -1)
    {
        
ReplyToCommand(client"[SM] Usage: sm_addban <time> <steamid> [reason]");
        return 
Plugin_Handled;
    }    
    
total_len += len;

    
/* Get steamid */
    
if ((len BreakString(arg_string[total_len], authidsizeof(authid))) != -1)
    {
        
total_len += len;
    }
    else
    {
        
total_len 0;
        
arg_string[0] = '\0';
    }

    
/* Verify steamid */
    
bool idValid false;
    if (!
strncmp(authid"STEAM_"6) && authid[7] == ':')
        
idValid true;
    else if (!
strncmp(authid"[U:"3))
        
idValid true;
    
    if (!
idValid)
    {
        
ReplyToCommand(client"[SM] %t""Invalid SteamID specified");
        return 
Plugin_Handled;
    }

    
int minutes StringToInt(time);

    
LogAction(client
              -
1
              
"\"%L\" added ban (minutes \"%d\") (id \"%s\") (reason \"%s\")"
              
client
              
minutes
              
authid
              
arg_string[total_len]);

if (
minutes || minutes 1)
        {
         
minutes 1;
        } 


BanIdentity(authid
                
minutes
                
BANFLAG_AUTHID
                
arg_string[total_len], 
                
"sm_addban"
                
client);

    
ReplyToCommand(client"[SM] %t""Ban added");

    return 
Plugin_Handled;
}

public 
Action Command_Unban(int clientint args)
{
    if (
args 1)
    {
        
ReplyToCommand(client"[SM] Usage: sm_unban <steamid|ip>");
        return 
Plugin_Handled;
    }

    
char arg[50];
    
GetCmdArgString(argsizeof(arg));

    
ReplaceString(argsizeof(arg), "\"""");    

    
int ban_flags;
    if (
IsCharNumeric(arg[0]))
    {
        
ban_flags |= BANFLAG_IP;
    }
    else
    {
        
ban_flags |= BANFLAG_AUTHID;
    }

    
LogAction(client, -1"\"%L\" removed ban (filter \"%s\")"clientarg);
    
RemoveBan(argban_flags"sm_unban"client);

    
ReplyToCommand(client"[SM] %t""Removed bans matching"arg);

    return 
Plugin_Handled;
}

public 
Action Command_AbortBan(int clientint args)
{
    if(!
CheckCommandAccess(client"sm_ban"ADMFLAG_BAN))
    {
        
ReplyToCommand(client"[SM] %t""No Access");
        return 
Plugin_Handled;
    }
    if(
g_IsWaitingForChatReason[client])
    {
        
g_IsWaitingForChatReason[client] = false;
        
ReplyToCommand(client"[SM] %t""AbortBan applied successfully");
    }
    else
    {
        
ReplyToCommand(client"[SM] %t""AbortBan not waiting for custom reason");
    }
    
    return 
Plugin_Handled;
}

public 
Action OnClientSayCommand(int client, const char[] command, const char[] sArgs)
{
    if(
g_IsWaitingForChatReason[client])
    {
        
g_IsWaitingForChatReason[client] = false;
        
PrepareBan(clientg_BanTarget[client], g_BanTime[client], sArgs);
        return 
Plugin_Stop;
    }

    return 
Plugin_Continue;


Last edited by KALASH NICOLE; 06-30-2017 at 02:26.
KALASH NICOLE is offline
KALASH NICOLE
Member
Join Date: Feb 2016
Old 07-01-2017 , 13:53   Re: Ban duration if not specified when using sm_ban
Reply With Quote #8

ok i finally got it working. i share my solution :

I had to edit ban.sp

i added :
PHP Code:
if (time 60 || time 1)
    {
     
time 60;
    } 
just before this line :

PHP Code:
PrepareBan(clienttargettimeArguments[len]); 

here is the full edited ban.sp code :

PHP Code:
/**
 * vim: set ts=4 :
 * =============================================================================
 * SourceMod Basecommands
 * Functionality related to banning.
 *
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
 * =============================================================================
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 3.0, as published by the
 * Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * As a special exception, AlliedModders LLC gives you permission to link the
 * code of this program (as well as its derivative works) to "Half-Life 2," the
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
 * by the Valve Corporation.  You must obey the GNU General Public License in
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
 * this exception to all derivative works.  AlliedModders LLC defines further
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
 * or <http://www.sourcemod.net/license.php>.
 *
 * Version: $Id$
 */

void PrepareBan(int clientint targetint time, const char[] reason)
{
    
int originalTarget GetClientOfUserId(g_BanTargetUserId[client]);

    if (
originalTarget != target)
    {
        if (
client == 0)
        {
            
PrintToServer("[SM] %t""Player no longer available");
        }
        else
        {
            
PrintToChat(client"[SM] %t""Player no longer available");
        }

        return;
    }

    
char name[MAX_NAME_LENGTH];
    
GetClientName(targetnamesizeof(name));

    if (!
time)
    {
        if (
reason[0] == '\0')
        {
            
ShowActivity(client"%t""Permabanned player"name);
        } else {
            
ShowActivity(client"%t""Permabanned player reason"namereason);
        }
    } else {
        if (
reason[0] == '\0')
        {
            
ShowActivity(client"%t""Banned player"nametime);
        } else {
            
ShowActivity(client"%t""Banned player reason"nametimereason);
        }
    }

    
LogAction(clienttarget"\"%L\" banned \"%L\" (minutes \"%d\") (reason \"%s\")"clienttargettimereason);

    if (
reason[0] == '\0')
    {
        
BanClient(targettimeBANFLAG_AUTO"Banned""Banned""sm_ban"client);
    }
    else
    {
        
BanClient(targettimeBANFLAG_AUTOreasonreason"sm_ban"client);
    }
}

void DisplayBanTargetMenu(int client)
{
    
Menu menu = new Menu(MenuHandler_BanPlayerList);

    
char title[100];
    
Format(titlesizeof(title), "%T:""Ban player"client);
    
menu.SetTitle(title);
    
menu.ExitBackButton true;

    
AddTargetsToMenu2(menuclientCOMMAND_FILTER_NO_BOTS|COMMAND_FILTER_CONNECTED);

    
menu.Display(clientMENU_TIME_FOREVER);
}

void DisplayBanTimeMenu(int client)
{
    
Menu menu = new Menu(MenuHandler_BanTimeList);

    
char title[100];
    
Format(titlesizeof(title), "%T: %N""Ban player"clientg_BanTarget[client]);
    
menu.SetTitle(title);
    
menu.ExitBackButton true;

    
menu.AddItem("0""Permanent");
    
menu.AddItem("10""10 Minutes");
    
menu.AddItem("30""30 Minutes");
    
menu.AddItem("60""1 Hour");
    
menu.AddItem("240""4 Hours");
    
menu.AddItem("1440""1 Day");
    
menu.AddItem("10080""1 Week");

    
menu.Display(clientMENU_TIME_FOREVER);
}

void DisplayBanReasonMenu(int client)
{
    
Menu menu = new Menu(MenuHandler_BanReasonList);

    
char title[100];
    
Format(titlesizeof(title), "%T: %N""Ban reason"clientg_BanTarget[client]);
    
menu.SetTitle(title);
    
menu.ExitBackButton true;
    
    
//Add custom chat reason entry first
    
menu.AddItem("""Custom reason (type in chat)");
    
    
//Loading configurable entries from the kv-file
    
char reasonName[100];
    
char reasonFull[255];
    
    
//Iterate through the kv-file
    
g_hKvBanReasons.GotoFirstSubKey(false);
    do
    {
        
g_hKvBanReasons.GetSectionName(reasonNamesizeof(reasonName));
        
g_hKvBanReasons.GetString(NULL_STRINGreasonFullsizeof(reasonFull));
        
        
//Add entry
        
menu.AddItem(reasonFullreasonName);
        
    } while (
g_hKvBanReasons.GotoNextKey(false));
    
    
//Reset kvHandle
    
g_hKvBanReasons.Rewind();

    
menu.Display(clientMENU_TIME_FOREVER);
}

public 
void AdminMenu_Ban(TopMenu topmenu,
                              
TopMenuAction action,
                              
TopMenuObject object_id,
                              
int param,
                              
char[] buffer,
                              
int maxlength)
{
    
//Reset chat reason first
    
g_IsWaitingForChatReason[param] = false;
    
    if (
action == TopMenuAction_DisplayOption)
    {
        
Format(buffermaxlength"%T""Ban player"param);
    }
    else if (
action == TopMenuAction_SelectOption)
    {
        
DisplayBanTargetMenu(param);
    }
}

public 
int MenuHandler_BanReasonList(Menu menuMenuAction actionint param1int param2)
{
    if (
action == MenuAction_End)
    {
        
delete menu;
    }
    else if (
action == MenuAction_Cancel)
    {
        if (
param2 == MenuCancel_ExitBack && hTopMenu)
        {
            
hTopMenu.Display(param1TopMenuPosition_LastCategory);
        }
    }
    else if (
action == MenuAction_Select)
    {
        if(
param2 == 0)
        {
            
//Chat reason
            
g_IsWaitingForChatReason[param1] = true;
            
PrintToChat(param1"[SM] %t""Custom ban reason explanation""sm_abortban");
        }
        else
        {
            
char info[64];
            
            
menu.GetItem(param2infosizeof(info));
            
            
PrepareBan(param1g_BanTarget[param1], g_BanTime[param1], info);
        }
    }
}

public 
int MenuHandler_BanPlayerList(Menu menuMenuAction actionint param1int param2)
{
    if (
action == MenuAction_End)
    {
        
delete menu;
    }
    else if (
action == MenuAction_Cancel)
    {
        if (
param2 == MenuCancel_ExitBack && hTopMenu)
        {
            
hTopMenu.Display(param1TopMenuPosition_LastCategory);
        }
    }
    else if (
action == MenuAction_Select)
    {
        
char info[32], name[32];
        
int useridtarget;

        
menu.GetItem(param2infosizeof(info), _namesizeof(name));
        
userid StringToInt(info);

        if ((
target GetClientOfUserId(userid)) == 0)
        {
            
PrintToChat(param1"[SM] %t""Player no longer available");
        }
        else if (!
CanUserTarget(param1target))
        {
            
PrintToChat(param1"[SM] %t""Unable to target");
        }
        else
        {
            
g_BanTarget[param1] = target;
            
g_BanTargetUserId[param1] = userid;
            
DisplayBanTimeMenu(param1);
        }
    }
}

public 
int MenuHandler_BanTimeList(Menu menuMenuAction actionint param1int param2)
{
    if (
action == MenuAction_End)
    {
        
delete menu;
    }
    else if (
action == MenuAction_Cancel)
    {
        if (
param2 == MenuCancel_ExitBack && hTopMenu)
        {
            
hTopMenu.Display(param1TopMenuPosition_LastCategory);
        }
    }
    else if (
action == MenuAction_Select)
    {
        
char info[32];

        
menu.GetItem(param2infosizeof(info));
        
g_BanTime[param1] = StringToInt(info);

        
DisplayBanReasonMenu(param1);
    }
}

public 
Action Command_Ban(int clientint args)
{
    if (
args 2)
    {
        
ReplyToCommand(client"[SM] Usage: sm_ban <#userid|name> <minutes|0> [reason]");
        return 
Plugin_Handled;
    }

    
int lennext_len;
    
char Arguments[256];
    
GetCmdArgString(Argumentssizeof(Arguments));

    
char arg[65];
    
len BreakString(Argumentsargsizeof(arg));

    
int target FindTarget(clientargtrue);
    if (
target == -1)
    {
        return 
Plugin_Handled;
    }

    
char s_time[12];
    if ((
next_len BreakString(Arguments[len], s_timesizeof(s_time))) != -1)
    {
        
len += next_len;
    }
    else
    {
        
len 0;
        
Arguments[0] = '\0';
    }

    

    
int time StringToInt(s_time);

    
g_BanTargetUserId[client] = GetClientUserId(target);

    if (
time 60 || time 1)
    {
     
time 60;
    }  

    
PrepareBan(clienttargettimeArguments[len]);

    return 
Plugin_Handled;

you have to recompile basebans.sp since ban.sp is just an #include



now all my server admins can only give a maximum of 60 minutes ban.

Last edited by KALASH NICOLE; 11-14-2018 at 15:07.
KALASH NICOLE 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 22:59.


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