AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [CS:GO] Bans with a reason (https://forums.alliedmods.net/showthread.php?t=264456)

Lannister 06-16-2015 17:20

[CS:GO] Bans with a reason
 
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!

ThatOneGuy 06-16-2015 17:33

Re: [CS:GO] Bans with a reason
 
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.

Lannister 06-16-2015 17:56

Re: [CS:GO] Bans with a reason
 
I don't use Sourcebans!

ThatOneGuy 06-17-2015 01:43

Re: [CS:GO] Bans with a reason
 
Nows the time to start ;)

Potato Uno 06-19-2015 04:32

Re: [CS:GO] Bans with a reason
 
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);



Lannister 06-19-2015 12:34

Re: [CS:GO] Bans with a reason
 
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!

Addicted. 06-19-2015 14:35

Re: [CS:GO] Bans with a reason
 
Quote:

Originally Posted by Lannister (Post 2309533)
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.

Potato Uno 06-20-2015 00:35

Re: [CS:GO] Bans with a reason
 
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);



Lannister 06-20-2015 13:14

Re: [CS:GO] Bans with a reason
 
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!

Potato Uno 06-21-2015 02:46

Re: [CS:GO] Bans with a reason
 
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!


All times are GMT -4. The time now is 05:15.

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