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

[L4D2 req] Fix plugin crash and timer errors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JLmelenchon
Senior Member
Join Date: Mar 2019
Old 08-17-2022 , 12:37   [L4D2 req] Fix plugin crash and timer errors
Reply With Quote #1

The plugin cause a consistent crash when the map is changed with sm_map or sm_changelevel.
Also many timer errors :

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
Code:
#pragma semicolon 1

#include <sourcemod>
#include <readyup>
#include <colors>
#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()
{
	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);
	
	LoadTranslations("kickloadstuckers.phrases");
}

public OnClientConnected(client)
{
	LoadingTimer[client] = CreateTimer(GetConVarFloat(cvarDuration), CheckClientIngame, client, TIMER_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:timer, any: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_SM, file, sizeof(file), "logs/stuckplayerlog.log");
	
		GetClientAuthString(client, steamid, sizeof(steamid));
		if (FindAdminByIdentity(AUTHMETHOD_STEAM, steamid) != INVALID_ADMIN_ID)
		{
			LogToFileEx(file, "%s - %N - NOT KICKED DUE TO ADMIN STATUS", steamid, client);
			return;
		}
	
		else if (IsInReady() == true)
		{
			CPrintToChatAll("%t {green}%i{default}s.", "stuck_chat", client, RoundToNearest(GetConVarFloat(cvarDuration)));
		}
		
		else (IsInReady() == false)
		{
			PrintToConsoleAll("%t %is.", "stuck_chat", client, RoundToNearest(GetConVarFloat(cvarDuration)));
		}
		
		KickClient(client, "%t", "stuck_kick");
		
		LogToFileEx(file, "%s - %N", steamid, client); // this logs their steamids and names. to be banned.
	}
}

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

Last edited by JLmelenchon; 08-17-2022 at 12:37.
JLmelenchon is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 08-17-2022 , 17:03   Re: [L4D2 req] Fix plugin crash and timer errors
Reply With Quote #2

Try removing TIMER_FLAG_NO_MAPCHANGE
anyway, the plugin is using old syntax, nowadays there are better ways to achieve the same with safe methods.
__________________
Marttt is online now
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-17-2022 , 18:19   Re: [L4D2 req] Fix plugin crash and timer errors
Reply With Quote #3

...I made somthing

in same topic

https://forums.alliedmods.net/showpo...9&postcount=67
__________________
Do not Private Message @me
Bacardi 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 12:04.


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