minimal update

This commit is contained in:
jenz 2023-09-02 18:47:21 +02:00
parent c00a625910
commit 32e8029679

View File

@ -97,9 +97,10 @@ public void OnPluginStart()
HookConVarChange((cvar1 = CreateConVar("sm_exclude_specs_avghour", "20", "How many players must be considered active on the server before specs are included in generating the average hour count")), Cvar_playerExcludeSpec);
g_iPlayerCount_excludeSpec = cvar1.IntValue;
delete cvar1;
g_hTimer_avg_hour_count = CreateTimer(1800.0, log_average_hour_count, _, TIMER_REPEAT);
//g_hTimer_avg_hour_count = CreateTimer(1800.0, log_average_hour_count, _, TIMER_REPEAT);
}
/*
public Action log_average_hour_count(Handle timer, any data)
{
int i_port = GetConVarInt(FindConVar("hostport"));
@ -113,6 +114,7 @@ public Action log_average_hour_count(Handle timer, any data)
g_hDatabase.Query(SQL_FinishedQuery, sQuery, _, DBPrio_Low);
return Plugin_Continue;
}
*/
public void Cvar_playerAFKTime(ConVar convar, const char[] oldValue, const char[] newValue)
{
@ -134,21 +136,22 @@ public int GetAveragePlayerActiveTimeServer()
{
int total_hours = 0;
int total_players = 0;
int spec_player_count = 0;
int active_player_count = 0;
for (int i = 0; i < MaxClients; i++)
{
//checking player count before deciding if including or excluding spectators from actual average
//the purpose of this is me (jenz) not boosting the hour average insanely when the server is very empty. (i often sit spec without playing and that ruins the generated average when low population because the count gets way too high due to me. But if i were actually playing it would instead be fine)
if (IsValidClient(i) && !IsFakeClient(i) && !IsClientSourceTV(i) && !is_bot_player[i] && PM_IsPlayerSteam(i) && GetClientIdleTime(i) < g_iPlayerAFKTime)
if (IsValidClient(i) && !IsFakeClient(i) && !IsClientSourceTV(i) && !is_bot_player[i] && PM_IsPlayerSteam(i) && GetClientIdleTime(i) < g_iPlayerAFKTime
&& (GetClientTeam(i) == CS_TEAM_T || GetClientTeam(i) == CS_TEAM_CT))
{
spec_player_count++;
active_player_count++;
}
}
for (int i = 0; i < MaxClients; i++)
{
if (IsValidClient(i) && !IsFakeClient(i) && !IsClientSourceTV(i) && !is_bot_player[i] && PM_IsPlayerSteam(i) && GetClientIdleTime(i) < g_iPlayerAFKTime)
{
if (spec_player_count <= g_iPlayerCount_excludeSpec && GetClientTeam(i) == CS_TEAM_SPECTATOR)
if (active_player_count <= g_iPlayerCount_excludeSpec && GetClientTeam(i) == CS_TEAM_SPECTATOR)
{
continue;
}