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

[L4D & L4D2] Kick Load Stuckers


Post New Thread Reply   
 
Thread Tools Display Modes
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 09-26-2016 , 07:44   Re: [L4D & L4D2] Kick Load Stuckers
Reply With Quote #61

Quote:
Originally Posted by Spirit_12 View Post
PHP Code:
#pragma semicolon 1

#include <sourcemod>
#define PLUGIN_VERSION "1.0.8"

public Plugin:myinfo 
{
    
name "L4D Kick Load Stuckers",
    
author "AtomicStryker",
    
description "Kicks Clients that get stuck in server connecting state",
    
version PLUGIN_VERSION,
    
url "http://forums.alliedmods.net/showthread.php?t=103203"
}

static 
Handle:LoadingTimer[MAXPLAYERS+1]     = INVALID_HANDLE;
static 
Handle:cvarDuration                     INVALID_HANDLE;

public 
OnPluginStart()
{
    
RegAdminCmd("sm_kickloading"KickLoadersADMFLAG_KICK"Kicks everyone Connected but not ingame");
    
CreateConVar(                "l4d_kickloadstuckers_version",     PLUGIN_VERSION" Version of L4D Kick Load Stuckers on this server ",                             FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
cvarDuration CreateConVar("l4d_kickloadstuckers_duration",     "60",             " How long before a connected but not ingame player is kicked. (default 60) ",     FCVAR_PLUGIN|FCVAR_NOTIFY);
}

public 
Action:KickLoaders(clientsargs)
{
    for (new 
1<= MaxClientsi++)
    {
        if (!
IsClientConnected(i)) continue;
        if (!
IsClientInGame(i))
        {
            
PrintToChatAll("%N was admin kicked for being stuck in connecting state"i);
            
            
//BanClient(i, 0, BANFLAG_AUTO, "Slowass Loading", "Slowass Loader");
            
KickClient(i"You were stuck Connecting for too long");
        }
    }
    return 
Plugin_Handled;
}

public 
OnClientConnected(client)
{
    
LoadingTimer[client] = CreateTimer(GetConVarFloat(cvarDuration), CheckClientIngameclientTIMER_FLAG_NO_MAPCHANGE); //on successfull connect the Timer is set in motion
}

public 
OnClientDisconnect(client)
{
    if ( !
AreHumansConnected() ) return;
    
    if (
LoadingTimer[client] != INVALID_HANDLE
    {
        
KillTimer(LoadingTimer[client]);
        
LoadingTimer[client] = INVALID_HANDLE;
    }
}

public 
Action:CheckClientIngame(Handle:timerany:client)
{
    
LoadingTimer[client] = INVALID_HANDLE;

    if (!
IsClientConnected(client)) return; //onclientdisconnect should handle this, but you never know
    
    
if (!IsClientInGame(client))
    {
        
//player log file code. name and steamid only
        
decl String:file[PLATFORM_MAX_PATH], String:steamid[128];
        
BuildPath(Path_SMfilesizeof(file), "logs/stuckplayerlog.log");
    
        
GetClientAuthId(clientAuthId_Steam2steamidsizeof(steamid));
        if (
FindAdminByIdentity(AUTHMETHOD_STEAMsteamid) != INVALID_ADMIN_ID)
        {
            
LogToFileEx(file"%s - %N - NOT KICKED DUE TO ADMIN STATUS"steamidclient);
            return;
        }
    
        
PrintToChatAll("%N was kicked for being stuck in connecting state for %i seconds"clientRoundToNearest(GetConVarFloat(cvarDuration)));
        
        
KickClient(client"You were stuck Connecting for too long");
        
        
LogToFileEx(file"%s - %N"steamidclient); // this logs their steamids and names. to be banned.
    
}
}

stock bool:AreHumansConnected()
{
    for (new 
1<= MaxClientsi++)
    {
        if (
IsClientConnected(i) && !IsFakeClient(i)) return true;
    }
    return 
false;

Oooooohhh, so that's how you use GetClientAuthId. Thanks for letting me know, also, please do not use this one with [L4D] Client Timeout Override plugin. Both conflicts for an unknown reason :/
cravenge is offline
Phoenix Rose
Junior Member
Join Date: Nov 2016
Old 09-13-2017 , 20:24   Re: [L4D & L4D2] Kick Load Stuckers
Reply With Quote #62

"heavily modded server"

i wonder why people are getting stuck in loading...
Phoenix Rose is offline
axelnieves2012
Senior Member
Join Date: Oct 2014
Location: Argentina
Old 01-19-2019 , 05:40   Re: [L4D & L4D2] Kick Load Stuckers
Reply With Quote #63

thanks you!! I was suffering because that issue.
axelnieves2012 is offline
foxhound27
AlliedModders Donor
Join Date: Sep 2019
Location: Argentina
Old 12-15-2019 , 12:13   Re: [L4D & L4D2] Kick Load Stuckers
Reply With Quote #64

new syntax source Spirit_12
Attached Files
File Type: sp Get Plugin or Get Source (l4d_kickloadstuckers.sp - 617 views - 2.9 KB)
foxhound27 is offline
JLmelenchon
Senior Member
Join Date: Mar 2019
Old 06-14-2022 , 15:00   Re: [L4D & L4D2] Kick Load Stuckers
Reply With Quote #65

Quote:
Originally Posted by foxhound27 View Post
new syntax source Spirit_12
Invalid timer error on player disconnect.
JLmelenchon is offline
JLmelenchon
Senior Member
Join Date: Mar 2019
Old 07-17-2022 , 16:02   Re: [L4D & L4D2] Kick Load Stuckers
Reply With Quote #66

Code:
L 07/17/2022 - 21:15:57: [SM] Exception reported: Invalid timer handle f9cd06f9 (error 3)
L 07/17/2022 - 21:15:57: [SM] Blaming: l4d_kickloadstuckers.smx
L 07/17/2022 - 21:15:57: [SM] Call stack trace:
L 07/17/2022 - 21:15:57: [SM]   [0] KillTimer
L 07/17/2022 - 21:15:57: [SM]   [1] Line 37, plugin.sp::OnClientDisconnect
L 07/17/2022 - 21:16:01: [SM] Exception reported: Invalid timer handle f9aa06e5 (error 1)
L 07/17/2022 - 21:16:01: [SM] Blaming: l4d_kickloadstuckers.smx
L 07/17/2022 - 21:16:01: [SM] Call stack trace:
L 07/17/2022 - 21:16:01: [SM]   [0] KillTimer
L 07/17/2022 - 21:16:01: [SM]   [1] Line 37, plugin.sp::OnClientDisconnect
Even if the plugin seems to work there are quite a lot of these errors, if someone can give a fix please.

edit: this plugin crash the server when you change map with admin command...

Last edited by JLmelenchon; 07-19-2022 at 04:08.
JLmelenchon is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-17-2022 , 18:19   Re: Kick Loading
Reply With Quote #67

I made new version, but I don't want make new topic of this.
This plugin works in any game.

I included @Spirit_12 admin check. It's not good but it's something.
Player steamid type depends by game... example TF2 use [U:1:28327177] if I remember right.
Change AuthId_Engine to AuthId_Steam2 if you get trouble and want use normal steamid type STEAM_0:1:123.


65 seconds is default duration while player can connecting into server. Change that bigger if you like.
Cvar kickloadstuckers_duration min. value is 60 seconds.
- I wanted avoid problems when plugin users use too small value. New players could download server files which take also time.

Code:
Admin command:
"sm_kickloading"                                                                 - Kick all players who are connecting into server but are not yet in game.

Plugin ConVar:
"kickloadstuckers_duration" = "65.0" min. 60.000000                              - Kick player after this many second if they still connecting to server

PHP Code:


public Plugin myinfo =
{
    
name "Kick Loading",
    
author "Bacardi",
    
description "Kick connecting players if takes too long",
    
version "18.8.2022",
    
url "http://www.sourcemod.net/"
};


ConVar kickloadstuckers_duration;
Handle playertimers[MAXPLAYERS+1];

public 
void OnPluginStart()
{
    
LoadTranslations("common.phrases");

    
RegAdminCmd("sm_kickloading"kickloadingADMFLAG_KICK"Kick all players who are connecting into server but are not yet in game.");
    
kickloadstuckers_duration CreateConVar("kickloadstuckers_duration""65.0""Kick player after this many second if they still connecting to server"_true60.0);
}


public 
Action kickloading(int clientint args)
{
    
bool kicked false;

    for(
int i 1<= MaxClientsi++)
    {
        
// Let's skip those who have not timer running
        
if(playertimers[i] == null)
            continue;

        
// To be safe side, skip these
        
if(== client || !IsClientConnected(i) || IsFakeClient(i))
            continue;

        if(!
IsClientInGame(i) && !IsClientInKickQueue(i))
        {
            
kicked true;
            
ShowActivity2(client"[SM]""Kicked connecting player %N"i);
            
LogAction(clienti"Admin \"%L\" kicked connecting player \"%L\""clienti);
            
KickClient(i"Admin kicked connecting players"i);
            
            
// Timer should end when player disconnect
        
}
    }

    if(!
kicked)
        
ReplyToTargetError(clientCOMMAND_TARGET_NONE);


    return 
Plugin_Handled;
}

public 
void OnClientDisconnect(int client)
{
    if(
playertimers[client] != null)
        
delete playertimers[client];
}

public 
void OnClientPutInServer(int client)
{
    if(
playertimers[client] != null)
        
delete playertimers[client];
}

public 
void OnClientConnected(int client)
{

    if(
playertimers[client] != null)
        
delete playertimers[client];

    if(
IsFakeClient(client))
        return;


    
char steamid[30];

    if(
GetClientAuthId(clientAuthId_Enginesteamidsizeof(steamid)))
    {
        
// Find player steamid from admin cache (this is not good method for admin immunity check, but we handle client upon connection...)
        
if(FindAdminByIdentity(AUTHMETHOD_STEAMsteamid) != INVALID_ADMIN_ID)
            return;
    }


    
DataPack pack;
    
playertimers[client] = CreateDataTimer(kickloadstuckers_duration.FloatValueTimerKickpack);

    
pack.WriteCell(client);
    
pack.WriteCell(GetClientUserId(client));
    
pack.Reset();

    
//PrintToServer(" - TimerKick created %N", client);
}


public 
Action TimerKick(Handle timerDataPack pack)
{
    
int index pack.ReadCell();

    
// clear handle first
    
playertimers[index] = null;

    
int client GetClientOfUserId(pack.ReadCell());

    
// when we not find client index anymore with given userid
    
if(client == 0)
        return 
Plugin_Continue;


    
// Player still not in game, player is not in kick queue
    
if(!IsClientInGame(client) && !IsClientInKickQueue(client))
    {
        
LogAction(0client"Kicked. Player \"%L\" connecting time takes longer than %0.0f seconds"clientkickloadstuckers_duration.FloatValue);
        
ShowActivity(0"Kicked player %N. Connecting time takes longer than %0.0f seconds"clientkickloadstuckers_duration.FloatValue);
        
KickClient(client"Kicked.\nYour connecting time into server takes longer than %0.0f seconds"kickloadstuckers_duration.FloatValue);
    }


    return 
Plugin_Continue;

Attached Files
File Type: sp Get Plugin or Get Source (kickloading.sp - 161 views - 3.2 KB)
__________________
Do not Private Message @me
Bacardi is offline
JLmelenchon
Senior Member
Join Date: Mar 2019
Old 08-18-2022 , 00:29   Re: [L4D & L4D2] Kick Load Stuckers
Reply With Quote #68

Cool i'll try that later.
JLmelenchon 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 04:22.


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