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;
}