excluding autismbots from rtv count

This commit is contained in:
jenz 2023-03-15 19:00:57 +01:00
parent c8bcee4377
commit 709a07a62b

View File

@ -64,9 +64,11 @@ ConVar g_Cvar_RTVAutoDisable;
ConVar g_Cvar_AFKTime;
ConVar g_Cvar_RTVRevoteDelay;
//check if autismbot
bool is_bot_player[MAXPLAYERS + 1];
bool g_CanRTV = false; // True if RTV loaded maps and is active.
bool g_RTVAllowed = false; // True if RTV is available to players. Used to delay rtv votes.
int g_Voters = 0; // Total voters connected. Doesn't include fake clients.
int g_Voters = 0; // Total voters connected. Doesnt include fake clients.
int g_Votes = 0; // Total number of "say rtv" votes
int g_VotesNeeded = 0; // Necessary votes before map vote begins. (voters * percent_needed)
bool g_Voted[MAXPLAYERS+1] = {false, ...};
@ -86,7 +88,7 @@ public void OnPluginStart()
g_Cvar_InitialDelay = CreateConVar("sm_rtv_initialdelay", "30.0", "Time (in seconds) before first RTV can be held", 0, true, 0.00);
g_Cvar_Interval = CreateConVar("sm_rtv_interval", "240.0", "Time (in seconds) after a failed RTV before another can be held", 0, true, 0.00);
g_Cvar_ChangeTime = CreateConVar("sm_rtv_changetime", "0", "When to change the map after a succesful RTV: 0 - Instant, 1 - RoundEnd, 2 - MapEnd", _, true, 0.0, true, 2.0);
g_Cvar_RTVPostVoteAction = CreateConVar("sm_rtv_postvoteaction", "0", "What to do with RTV's after a mapvote has completed. 0 - Allow, success = instant change, 1 - Deny", _, true, 0.0, true, 1.0);
g_Cvar_RTVPostVoteAction = CreateConVar("sm_rtv_postvoteaction", "0", "What to do with RTVs after a mapvote has completed. 0 - Allow, success = instant change, 1 - Deny", _, true, 0.0, true, 1.0);
g_Cvar_RTVAutoDisable = CreateConVar("sm_rtv_autodisable", "0", "Automatically disable RTV when map time is over.", _, true, 0.0, true, 1.0);
g_Cvar_AFKTime = CreateConVar("sm_rtv_afk_time", "180", "AFK Time in seconds after which a player is not counted in the rtv ratio");
g_Cvar_RTVRevoteDelay = CreateConVar("sm_rtv_revote_delay", "5", "Delay in seconds before a player can vote for RTV after undoing");
@ -142,14 +144,38 @@ public void OnClientPutInServer(int client)
public void OnClientDisconnect(int client)
{
if (g_Voted[client])
{
g_Voted[client] = false;
g_iTimeTillRTV[client] = 0;
g_Votes--;
}
is_bot_player[client] = false;
if (g_Voted[client])
{
g_Voted[client] = false;
g_iTimeTillRTV[client] = 0;
g_Votes--;
}
UpdateRTV();
UpdateRTV();
}
public void OnClientPostAdminCheck(int client)
{
is_bot_player[client] = false;
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
if (StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false))
{
is_bot_player[client] = true;
}
if (StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false))
{
is_bot_player[client] = true;
}
if (StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false))
{
is_bot_player[client] = true;
}
if (StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false))
{
is_bot_player[client] = true;
}
}
public void OnPlayerChangedTeam(Handle event, const char[] name, bool dontBroadcast)
@ -159,48 +185,48 @@ public void OnPlayerChangedTeam(Handle event, const char[] name, bool dontBroadc
void UpdateRTV()
{
g_Voters = 0;
int iVotersSteam;
int iVotersNoSteam;
g_Voters = 0;
int iVotersSteam;
int iVotersNoSteam;
for (int i=1; i<=MaxClients; i++)
{
if (IsClientInGame(i) && !IsFakeClient(i))
{
if (GetClientIdleTime(i) >= g_Cvar_AFKTime.IntValue)
continue;
for (int i=1; i<=MaxClients; i++)
{
if (IsClientInGame(i) && !IsFakeClient(i) && !is_bot_player[i])
{
if (GetClientIdleTime(i) >= g_Cvar_AFKTime.IntValue)
continue;
if (PM_IsPlayerSteam(i))
iVotersSteam++;
else
iVotersNoSteam++;
}
}
if (PM_IsPlayerSteam(i))
iVotersSteam++;
else
iVotersNoSteam++;
}
}
// g_Voters = GetTeamClientCount(2) + GetTeamClientCount(3);
g_Voters = iVotersSteam + iVotersNoSteam;
int iVotesNeededSteam = RoundToFloor(float(iVotersSteam) * GetConVarFloat(g_Cvar_Steam_Needed));
int iVotesNeededNoSteam = RoundToFloor(float(iVotersNoSteam) * GetConVarFloat(g_Cvar_NoSteam_Needed));
g_Voters = iVotersSteam + iVotersNoSteam;
int iVotesNeededSteam = RoundToFloor(float(iVotersSteam) * GetConVarFloat(g_Cvar_Steam_Needed));
int iVotesNeededNoSteam = RoundToFloor(float(iVotersNoSteam) * GetConVarFloat(g_Cvar_NoSteam_Needed));
g_VotesNeeded = iVotesNeededSteam + iVotesNeededNoSteam;
g_VotesNeeded = iVotesNeededSteam + iVotesNeededNoSteam;
if (!g_CanRTV)
{
return;
}
if (!g_CanRTV)
{
return;
}
if (g_Votes &&
g_Voters &&
g_Votes >= g_VotesNeeded &&
RTVAllowed())
{
if (g_Cvar_RTVPostVoteAction.IntValue == 1 && HasEndOfMapVoteFinished())
{
return;
}
if (g_Votes &&
g_Voters &&
g_Votes >= g_VotesNeeded &&
RTVAllowed())
{
if (g_Cvar_RTVPostVoteAction.IntValue == 1 && HasEndOfMapVoteFinished())
{
return;
}
StartRTV();
}
StartRTV();
}
}
public void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs)
@ -426,7 +452,7 @@ public Action Command_DebugRTV(int client, int args)
for (int i=1; i<=MaxClients; i++)
{
if (IsClientInGame(i) && !IsFakeClient(i))
if (IsClientInGame(i) && !IsFakeClient(i) && !is_bot_player[i])
{
if (GetClientIdleTime(i) >= g_Cvar_AFKTime.IntValue)
continue;