Raised This Month: $ Target: $400
 0% 

[CS:GO] Bans with a reason


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lannister
Veteran Member
Join Date: Apr 2015
Old 06-16-2015 , 17:20   [CS:GO] Bans with a reason
Reply With Quote #1

Hello community.

I wonder if it is possible to make a plugin which bans a player for a determined ammount of time and a reason, this mean, each reason will have a determined ammount of time, this will be useful to have more "control" to your server since punishment will depend on the crime.

Something like.

Ban reason: "abusive" "time: xxx"
"insulting admin" "time: xxx"

I hope i explain myself well, thanks!
Lannister is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 06-16-2015 , 17:33   Re: [CS:GO] Bans with a reason
Reply With Quote #2

remove access to banning from web panel and client commands for sourcebans banning, then use the menu options, which can have access set independently from the client commands, to define the reasons/lengths that are selectable.
__________________
ThatOneGuy is offline
Lannister
Veteran Member
Join Date: Apr 2015
Old 06-16-2015 , 17:56   Re: [CS:GO] Bans with a reason
Reply With Quote #3

I don't use Sourcebans!
Lannister is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 06-17-2015 , 01:43   Re: [CS:GO] Bans with a reason
Reply With Quote #4

Nows the time to start ;)
__________________
ThatOneGuy is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 06-19-2015 , 04:32   Re: [CS:GO] Bans with a reason
Reply With Quote #5

You probably can write a wrapper SM function that calls the BanClient() native:

https://sm.alliedmods.net/api/index....d=show&id=295&

I set 15 minutes aside and threw this together. I have no idea if it works, or if it even compiles (don't have the SM compiler here) but hopefully someone else can finish this up for you:

PHP Code:
#include <sourcemod>

public Plugin:myinfo
{
    
name            "Advanced Client Banning Plugin",
    
author            "AlliedModders Plugin Requests Forum",
    
description        "Bans a client for a specific duration, the duration depending on the reason.",
    
version            "1.0.0.0",
    
url                "http://www.sourcemod.net"
}

public 
OnPluginStart()
{
    
RegAdminCmd("sm_advban"ClientBanADMFLAG_BAN"Enter the client index and a reason to ban a client for a specified duration.");
}


public 
Action:ClientBan(iClientnArgs)
{
    if (
nArgs != 2)
    {
        
ReplyToCommand(iClient"Usage: sm_advban <client index> <reason>");
    }
    new 
String:ClientIndex[4];
    new 
String:Reason[100];
    new 
Punishment// in minutes
    
GetCmdArg(1ClientIndexsizeof(ClientIndex));
    
GetCmdArg(2Reasonsizeof(Reason));
    
    if (
StrContains(Reason"insulting admin"false))
        
Punishment 60// 60 minutes
    
else if (StrContains(Reason"abusive"false))
        
Punishment 45// 45 minutes
    // you can add more conditionals here for other reasons, copying the "else if" statement, changing the
    // 2nd parameter of StrContains, and changing the Punishment variable value (which is the number of minutes to ban the player for).
    
    
BanClient(StringToInt(ClientIndex), PunishmentReasonReason);


Last edited by Potato Uno; 06-19-2015 at 04:33.
Potato Uno is offline
Lannister
Veteran Member
Join Date: Apr 2015
Old 06-19-2015 , 12:34   Re: [CS:GO] Bans with a reason
Reply With Quote #6

hello, first of all thanks alot for your help! If i use compiler it gives me 2 errors

error 055: start of function body without function header
error 035: argument type mismatch <argument 3>

Hope someone could fix it!
Lannister is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 06-19-2015 , 14:35   Re: [CS:GO] Bans with a reason
Reply With Quote #7

Quote:
Originally Posted by Lannister View Post
hello, first of all thanks alot for your help! If i use compiler it gives me 2 errors

error 055: start of function body without function header
error 035: argument type mismatch <argument 3>

Hope someone could fix it!
Can you tell us what lines the errors are on? Or at least tell us which lines because there are no numbers on the forum.
Addicted. is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 06-20-2015 , 00:35   Re: [CS:GO] Bans with a reason
Reply With Quote #8

Fixed the compilation errors. I forgot this (https://spider.limetech.org/) thing by Asher existed.

This was not tested on a server, so test it yourself using a dummy account or something.

The problems were:

- Forgot the = after Plugin:myinfo
- Forgot to include the ban flag parameter in BanClient()
- Added a IsClientInGame check

PHP Code:
#include <sourcemod>

public Plugin:myinfo 
{
    
name            "Advanced Client Banning Plugin",
    
author            "AlliedModders Plugin Requests Forum",
    
description        "Bans a client for a specific duration, the duration depending on the reason.",
    
version            "1.0.0.0",
    
url                "http://www.sourcemod.net"
}

public 
OnPluginStart()
{
    
RegAdminCmd("sm_advban"ClientBanADMFLAG_BAN"Enter the client index and a reason to ban a client for a specified duration.");
}


public 
Action:ClientBan(iClientnArgs)
{
    if (
nArgs != 2)
    {
        
ReplyToCommand(iClient"Usage: sm_advban <client index> <reason>");
    }
    new 
String:ClientIndexStr[4];
    new 
String:Reason[100];
    new 
Punishment// in minutes
    
GetCmdArg(1ClientIndexStrsizeof(ClientIndexStr));
    
GetCmdArg(2Reasonsizeof(Reason));
    
    new 
ClientIndex StringToInt(ClientIndexStr);
    if (!
IsClientInGame(ClientIndex))
    {
        
ReplyToCommand(iClient"Invalid Client Index. Enter 'status' in the console, locate the player to ban, then locate their client index.");
        return;
    }
    
    if (
StrContains(Reason"insulting admin"false))
        
Punishment 60// 60 minutes
    
else if (StrContains(Reason"abusive"false))
        
Punishment 45// 45 minutes
    // you can add more conditionals here for other reasons, copying the "else if" statement, changing the
    // 2nd parameter of StrContains, and changing the Punishment variable value (which is the number of minutes to ban the player for).
    
    
BanClient(ClientIndexPunishmentBANFLAG_AUTOReasonReason);

Potato Uno is offline
Lannister
Veteran Member
Join Date: Apr 2015
Old 06-20-2015 , 13:14   Re: [CS:GO] Bans with a reason
Reply With Quote #9

When i try to ban someone called "Yacante" it tells me "unknown command sm_advan"

I also tried with sm_rcon

sm_rcon sm_advban "Yacante" "insulting admin"

L 06/20/2015 - 14:12:01: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 06/20/2015 - 14:12:01: [SM] Displaying call stack trace for plugin "advban.smx":
L 06/20/2015 - 14:12:01: [SM] [0] Line 31

What i'm doing wrong? also, if plugins works, could you please add a section in !admin menu? so we can easy select the target and the reason?

Thansk alot and i'm sure this will be really really useful for many people, you should release this in the news plugin section!

Last edited by Lannister; 06-20-2015 at 13:15.
Lannister is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 06-21-2015 , 02:46   Re: [CS:GO] Bans with a reason
Reply With Quote #10

I haven't written the support for entering player user names (mainly because I have no idea how to and plus I have a ton of other things to finish up). Use the client ID instead of the username.

If you type "status" onto the console (client console or server console) it will list each player's name with an index number (usually a number within 1 to 100), along with their steam ID and everything else. Say the guy "Yacante" has the client ID #53. Then you enter 'sm_advban 53 "insulting admin"' and it should ban them for 60 minutes. Try that and see if it works.

You should use the status command on the console to get the client ID anyway, since some players can come in with untypable names (with Russian or Chinese or non-UTF-8 characters).

EDIT: I also have no experience on admin menu integration. If anyone else is willing to lend a few minutes of their time for admin menu integration then they can write that support here. Thanks!

Last edited by Potato Uno; 06-21-2015 at 02:47.
Potato Uno 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 05:15.


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