Raised This Month: $32 Target: $400
 8% 

AutoBan on player exit


Post New Thread Reply   
 
Thread Tools Display Modes
midnight9
Senior Member
Join Date: Nov 2012
Old 12-28-2017 , 04:40   Re: AutoBan on player exit
Reply With Quote #11

Quote:
Originally Posted by paul181516 View Post
Doesnt work, im already tryed
Try adding some debug prints to the code to see what is happening.
midnight9 is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 12-28-2017 , 09:20   Re: AutoBan on player exit
Reply With Quote #12

Quote:
Originally Posted by shanapu View Post
according to https://wiki.alliedmods.net/Generic_...yer_disconnect the reason should be "self" and not "Disconnect by user."
I believe that wiki may be quite old, and might be in need of an update:

The reason has been "Disconnect by user" in CS:S for the past ~5 years, when an user quits manually on his/her own decision, but of course, it isn't completely impossible that Valve might do the same thing differently in two different games.

Maybe try OnClientDisconnect instead.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].

Last edited by DarkDeviL; 12-28-2017 at 09:21.
DarkDeviL is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 12-28-2017 , 10:27   Re: AutoBan on player exit
Reply With Quote #13

Quote:
Originally Posted by arne1288 View Post
I believe that wiki may be quite old, and might be in need of an update:

The reason has been "Disconnect by user" in CS:S for the past ~5 years, when an user quits manually on his/her own decision, but of course, it isn't completely impossible that Valve might do the same thing differently in two different games.

Maybe try OnClientDisconnect instead.
good to know! that's why referred to the wiki.
Maybe the issue comes from the extra point "." in 'StrEqual'
"Disconnect by user." != "Disconnect by user"

As midnight9 said, add some debug messages to see if the event fires and if the PUB check works fine.
Maybe also try PugSetup_GetGameState() in combination
__________________
coding & free software
shanapu is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 12-28-2017 , 10:41   Re: AutoBan on player exit
Reply With Quote #14

Quote:
Originally Posted by shanapu View Post
good to know! that's why referred to the wiki.
Maybe the issue comes from the extra point "." in 'StrEqual'
"Disconnect by user." != "Disconnect by user"

As midnight9 said, add some debug messages to see if the event fires and if the PUB check works fine.
Maybe also try PugSetup_GetGameState() in combination
My fault, the correct one is the one with the dot in the end.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
paul181516
Junior Member
Join Date: Aug 2017
Location: Colombia
Old 12-28-2017 , 21:12   Re: AutoBan on player exit
Reply With Quote #15

Anyone, the reason of user disconnect is just "Disconnect". I have to put a log that prints the reason of disconnection, and the plugin show me "Kick by admin" "Disconnected" "Timed out" and "Error" so i rewrite that little part and add some other things to the plugin. Anyway i have this little problem, all PrintToChatAll and LogMessage do twice, no idea why, thanks a lot shanapu and midnight9 for help me.

I add some features like a cvar to control time of ban and admin inmunitty. Also i steal a little function from another plugins, and this functions get clients count and start plugin only when players are more than the cvar. But i dont know if i do correctly

PHP Code:
#include <cstrike>
#include <sourcemod>
#include "include/pugsetup.inc"

/* Handles to convars used by plugin */
ConVar sm_matchkick_bantime;
ConVar sm_matchkick_minplayer;

public 
Plugin:myinfo = {
name "Matchkick",
author "paul181516",
description "Bans a player who is disconnected on a live match",
version "1.0",
url "http://CounterBucaraman.ga"
}

public 
OnPluginStart()
{
    
sm_matchkick_bantime CreateConVar("sm_matchkick_bantime""360""Duracion del baneo por abandonar el PUG.");
    
sm_matchkick_minplayer CreateConVar("sm_matchkick_minplayer""7""Jugadores necesarios para iniciar el plugin.");
    
HookEvent("player_disconnect"Event_PlayerDisconnectEventHookMode_Post);
}

stock PlayerCountIsCorrect()
{
    new 
k;
    for(new 
1<= MaxClientsi++)
    {
        if(
k++ >= GetConVarInt(sm_matchkick_minplayer))
        {
            return 
true;
        }
    }
    
    return 
false;
}

public 
Action:Event_PlayerDisconnect(Handle:eventString:name[], bool:dontBroadcast)
{
    if(
PugSetup_IsMatchLive() && PlayerCountIsCorrect())
    {
        new 
client GetClientOfUserId(GetEventInt(event"userid"));
        if(
GetUserAdmin(client) == INVALID_ADMIN_ID)
        {
            
decl String:reason[128];
            
GetEventString(event"reason"reasonsizeof(reason));
            if (
StrEqual(reason"Disconnect"))
            {
                
BanClient(clientGetConVarInt(sm_matchkick_bantime), BANFLAG_AUTHID"Fue baneado por salirse en medio de un PUG!""Fuiste baneado por salirte en medio de un PUG! ¿Donde esta tu honor, basura?");
                
LogMessage("%L fue baneado por salirse en medio de un PUG"client);
                
PrintToChatAll("%N fue baneado por salirse en medio de un PUG"client);
            }
        }
    }
    return 
Plugin_Handled;


Last edited by paul181516; 12-29-2017 at 02:09.
paul181516 is offline
Send a message via MSN to paul181516 Send a message via Skype™ to paul181516
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 01-02-2018 , 10:09   Re: AutoBan on player exit
Reply With Quote #16

Quote:
Originally Posted by paul181516 View Post
... Anyway i have this little problem, all PrintToChatAll and LogMessage do twice, no idea why,...
I faced this problem few times in the past, every time cause I was running the plugin two times.
Check your plugins folder and subfolders for a duplicate plugin, maybe with an old name or named after compiled on webcompiler (plugin(2).smx,...)


Quote:
Originally Posted by paul181516 View Post
But i dont know if i do correctly
use https://sm.alliedmods.net/new-api/cl...GetClientCount instead your stock
just a fast edit, not tested, should work, still things to improve.
PHP Code:
#include <cstrike>
#include <sourcemod>
#include <include/pugsetup.inc>

/* Handles to convars used by plugin */
ConVar sm_matchkick_bantime;
ConVar sm_matchkick_minplayer;

public 
Plugin:myinfo = {
name "Matchkick",
author "paul181516",
description "Bans a player who is disconnected on a live match",
version "1.1",
url "http://CounterBucaraman.ga"
}

public 
OnPluginStart()
{
    
sm_matchkick_bantime CreateConVar("sm_matchkick_bantime""360""Duracion del baneo por abandonar el PUG.");
    
sm_matchkick_minplayer CreateConVar("sm_matchkick_minplayer""7""Jugadores necesarios para iniciar el plugin.");
    
HookEvent("player_disconnect"Event_PlayerDisconnectEventHookMode_Post);
}

public 
Event_PlayerDisconnect(Handle:eventString:name[], bool:dontBroadcast)
{
    if(
PugSetup_IsMatchLive())
    {
        if (
GetClientCount(true) >= GetConVarInt(sm_matchkick_minplayer))
        {
            new 
client GetClientOfUserId(GetEventInt(event"userid"));
            if(
GetUserAdmin(client) == INVALID_ADMIN_ID)
            {
                
decl String:reason[128];
                
GetEventString(event"reason"reasonsizeof(reason));
                if (
StrEqual(reason"Disconnect"))
                {
                    
BanClient(clientGetConVarInt(sm_matchkick_bantime), BANFLAG_AUTHID"Fue baneado por salirse en medio de un PUG!""Fuiste baneado por salirte en medio de un PUG! ¿Donde esta tu honor, basura?");
                    
LogMessage("%L fue baneado por salirse en medio de un PUG"client);
                    
PrintToChatAll("%N fue baneado por salirse en medio de un PUG"client);
                }
            }
        }
    }

__________________
coding & free software
shanapu is offline
paul181516
Junior Member
Join Date: Aug 2017
Location: Colombia
Old 01-02-2018 , 16:56   Re: AutoBan on player exit
Reply With Quote #17

Quote:
Originally Posted by shanapu View Post
I faced this problem few times in the past, every time cause I was running the plugin two times.
Check your plugins folder and subfolders for a duplicate plugin, maybe with an old name or named after compiled on webcompiler (plugin(2).smx,...)



use https://sm.alliedmods.net/new-api/cl...GetClientCount instead your stock
just a fast edit, not tested, should work, still things to improve.
PHP Code:
#include <cstrike>
#include <sourcemod>
#include <include/pugsetup.inc>

/* Handles to convars used by plugin */
ConVar sm_matchkick_bantime;
ConVar sm_matchkick_minplayer;

public 
Plugin:myinfo = {
name "Matchkick",
author "paul181516",
description "Bans a player who is disconnected on a live match",
version "1.1",
url "http://CounterBucaraman.ga"
}

public 
OnPluginStart()
{
    
sm_matchkick_bantime CreateConVar("sm_matchkick_bantime""360""Duracion del baneo por abandonar el PUG.");
    
sm_matchkick_minplayer CreateConVar("sm_matchkick_minplayer""7""Jugadores necesarios para iniciar el plugin.");
    
HookEvent("player_disconnect"Event_PlayerDisconnectEventHookMode_Post);
}

public 
Event_PlayerDisconnect(Handle:eventString:name[], bool:dontBroadcast)
{
    if(
PugSetup_IsMatchLive())
    {
        if (
GetClientCount(true) >= GetConVarInt(sm_matchkick_minplayer))
        {
            new 
client GetClientOfUserId(GetEventInt(event"userid"));
            if(
GetUserAdmin(client) == INVALID_ADMIN_ID)
            {
                
decl String:reason[128];
                
GetEventString(event"reason"reasonsizeof(reason));
                if (
StrEqual(reason"Disconnect"))
                {
                    
BanClient(clientGetConVarInt(sm_matchkick_bantime), BANFLAG_AUTHID"Fue baneado por salirse en medio de un PUG!""Fuiste baneado por salirte en medio de un PUG! ¿Donde esta tu honor, basura?");
                    
LogMessage("%L fue baneado por salirse en medio de un PUG"client);
                    
PrintToChatAll("%N fue baneado por salirse en medio de un PUG"client);
                }
            }
        }
    }

Thanks a lot, but the first problem was not that your second solution was great, much easy.
I read and idea from a guy to stop the double plugin exec
Quote:
Originally Posted by lake393 View Post
I was under the impression that this was normal for SourceMod, so what I did was create a string to contain the UserId of the person who triggered the event last. If the same userId is seen again, it aborts by returning.
But i dont know how save data on string, yes stupid things, but is my first plugin haha. Thanks a lot

Last edited by paul181516; 01-02-2018 at 20:43.
paul181516 is offline
Send a message via MSN to paul181516 Send a message via Skype™ to paul181516
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 11-12-2019 , 23:16   Re: AutoBan on player exit
Reply With Quote #18

a user asked me for a warmod version...
PHP Code:
#include <cstrike>
#include <sourcemod>
#include <sdktools>
#include <warmod>

/* Handles to convars used by plugin */
ConVar sm_matchkick_bantime;
ConVar sm_matchkick_minplayer;

public 
Plugin:myinfo = {
name "Matchkick for warmod",
author "paul181516,shanapu",
description "Bans a player who is disconnected on a live match",
version "1.2",
url ""
}
bool g_bIsLive false;

public 
OnPluginStart()
{
    
sm_matchkick_bantime CreateConVar("sm_matchkick_bantime""360""Duracion del baneo por abandonar el PUG.");
    
sm_matchkick_minplayer CreateConVar("sm_matchkick_minplayer""7""Jugadores necesarios para iniciar el plugin.");
    
HookEvent("player_disconnect"Event_PlayerDisconnectEventHookMode_Post);
}

public 
void OnLiveOn3()
{
    
g_bIsLive true;
}

public 
void OnResetMatch()
{
    
g_bIsLive false;
}

public 
void OnEndMatch(const char[] ct_nameint ct_scoreint t_score, const char[] t_name)
{
    
g_bIsLive false;
}

public 
Event_PlayerDisconnect(Handle:eventString:name[], bool:dontBroadcast)
{
    if(
g_bIsLive)
    {
        if (
GetClientCount(true) >= GetConVarInt(sm_matchkick_minplayer))
        {
            new 
client GetClientOfUserId(GetEventInt(event"userid"));
            if(
GetUserAdmin(client) == INVALID_ADMIN_ID)
            {
                
decl String:reason[128];
                
GetEventString(event"reason"reasonsizeof(reason));
                if (
StrEqual(reason"Disconnect"))
                {
                    
BanClient(clientGetConVarInt(sm_matchkick_bantime), BANFLAG_AUTHID"Fue baneado por salirse en medio de un PUG!""Fuiste baneado por salirte en medio de un PUG! ¿Donde esta tu honor, basura?");
                    
LogMessage("%L fue baneado por salirse en medio de un PUG"client);
                    
PrintToChatAll("%N fue baneado por salirse en medio de un PUG"client);
                }
            }
        }
    }

https://warmod.bitbucket.io/scriptin...ude/warmod.inc

still dirty and worthy of improvement
__________________
coding & free software

Last edited by shanapu; 11-12-2019 at 23:18.
shanapu is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 11-13-2019 , 04:03   Re: AutoBan on player exit
Reply With Quote #19

Here a working and with more features version https://forums.alliedmods.net/showthread.php?t=319581
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
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 15:44.


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