forked from UNLOZE/sm-plugins
changing map chooser again to use numbers of votes instead of percentages
This commit is contained in:
@@ -68,7 +68,7 @@ ConVar g_Cvar_RTVRevoteDelay;
|
||||
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_VotesNeeded = 0; // Necessary votes before map vote begins. (2023: voters average hour count * percent_needed)
|
||||
int g_VotesNeeded = 0; // Necessary votes before map vote begins.
|
||||
bool g_Voted[MAXPLAYERS+1] = {false, ...};
|
||||
int g_iTimeTillRTV[MAXPLAYERS+1] = {0, ...};
|
||||
|
||||
@@ -200,51 +200,38 @@ public int Native_GetRtvPercentageForClient(Handle plugin, int numParams)
|
||||
}
|
||||
|
||||
UpdateRTV();
|
||||
int clients_percentage = 0;
|
||||
if (g_VotesNeeded == 0)
|
||||
{
|
||||
clients_percentage = RoundToFloor((GetPlayerWorthRTV_(client) / float(100)) * 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
clients_percentage = RoundToFloor((GetPlayerWorthRTV_(client) / float(g_VotesNeeded)) * 100);
|
||||
}
|
||||
if (clients_percentage > 100)
|
||||
{
|
||||
clients_percentage = 100;
|
||||
}
|
||||
return clients_percentage;
|
||||
int player_worth_rtv = GetPlayerWorthRTV_boost_(client);
|
||||
return player_worth_rtv;
|
||||
}
|
||||
|
||||
void UpdateRTV()
|
||||
void update_g_VotesNeeded()
|
||||
{
|
||||
int iVotersSteam = 0;
|
||||
int iVoters = 0;
|
||||
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++;
|
||||
iVoters++;
|
||||
}
|
||||
}
|
||||
g_VotesNeeded = RoundToFloor(iVoters * GetConVarFloat(g_Cvar_Steam_Needed));
|
||||
if (g_VotesNeeded == 0)
|
||||
{
|
||||
g_VotesNeeded = 1;
|
||||
}
|
||||
}
|
||||
|
||||
g_VotesNeeded = RoundToFloor(float(iVotersSteam) * GetConVarFloat(g_Cvar_Steam_Needed));
|
||||
|
||||
g_VotesNeeded *= GetAveragePlayerTimeOnServerRTV();
|
||||
|
||||
void UpdateRTV()
|
||||
{
|
||||
if (!g_CanRTV)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int Votes = get_voted_rtv();
|
||||
if (Votes &&
|
||||
iVotersSteam &&
|
||||
Votes >= g_VotesNeeded &&
|
||||
RTVAllowed())
|
||||
update_g_VotesNeeded();
|
||||
if (get_voted_rtv() >= g_VotesNeeded && RTVAllowed())
|
||||
{
|
||||
if (g_Cvar_RTVPostVoteAction.IntValue == 1 && HasEndOfMapVoteFinished())
|
||||
{
|
||||
@@ -262,7 +249,8 @@ public int get_voted_rtv()
|
||||
{
|
||||
if (IsValidClient(i) && g_Voted[i])
|
||||
{
|
||||
Votes += GetPlayerWorthRTV_(i);
|
||||
int player_worth_boost = GetPlayerWorthRTV_boost_(i);
|
||||
Votes += player_worth_boost;
|
||||
}
|
||||
}
|
||||
return Votes;
|
||||
@@ -322,32 +310,12 @@ void AttemptRTV(int client)
|
||||
ReplyToCommand(client, "[RTVE] %t", "Wait Before Revoting", g_iTimeTillRTV[client] - GetTime());
|
||||
return;
|
||||
}
|
||||
update_g_VotesNeeded();
|
||||
int Votes = get_voted_rtv();
|
||||
|
||||
if (g_Voted[client])
|
||||
{
|
||||
float rtv_worth = GetPlayerWorthRTV_boost_(client);
|
||||
int Votes = get_voted_rtv();
|
||||
if (g_VotesNeeded == 0)
|
||||
{
|
||||
g_VotesNeeded = Votes;
|
||||
}
|
||||
int rtv_percentage_reached = RoundToFloor((float(Votes) / float(g_VotesNeeded)) * 100);
|
||||
if (rtv_percentage_reached > 100)
|
||||
{
|
||||
rtv_percentage_reached = 100;
|
||||
}
|
||||
int clients_percentage = RoundToFloor((GetPlayerWorthRTV_(client) / float(g_VotesNeeded)) * 100);
|
||||
if (clients_percentage > 100)
|
||||
{
|
||||
clients_percentage = 100;
|
||||
}
|
||||
ReplyToCommand(client, "[RTVE] %t", "Already Voted", rtv_percentage_reached, rtv_worth, clients_percentage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PM_IsPlayerSteam(client))
|
||||
{
|
||||
ReplyToCommand(client, "Disabled rtv participation for nosteamers.");
|
||||
ReplyToCommand(client, "[RTVE] %t", "Already Voted", Votes, g_VotesNeeded, GetPlayerWorthRTV_boost_(client));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -356,23 +324,9 @@ void AttemptRTV(int client)
|
||||
|
||||
g_Voted[client] = true;
|
||||
|
||||
int Votes = get_voted_rtv();
|
||||
float rtv_worth = GetPlayerWorthRTV_boost_(client);
|
||||
if (g_VotesNeeded == 0)
|
||||
{
|
||||
g_VotesNeeded = Votes;
|
||||
}
|
||||
int rtv_percentage_reached = RoundToFloor((float(Votes) / float(g_VotesNeeded)) * 100);
|
||||
if (rtv_percentage_reached > 100 || rtv_percentage_reached < 0)
|
||||
{
|
||||
rtv_percentage_reached = 100;
|
||||
}
|
||||
int clients_percentage = RoundToFloor((GetPlayerWorthRTV_(client) / float(g_VotesNeeded)) * 100);
|
||||
if (clients_percentage > 100 || clients_percentage < 0)
|
||||
{
|
||||
clients_percentage = 100;
|
||||
}
|
||||
PrintToChatAll("[RTVE] %t", "RTV Requested", name, rtv_percentage_reached, rtv_worth, clients_percentage);
|
||||
Votes = get_voted_rtv();
|
||||
|
||||
PrintToChatAll("[RTVE] %t", "RTV Requested", name, Votes, g_VotesNeeded, GetPlayerWorthRTV_boost_(client));
|
||||
|
||||
if (Votes >= g_VotesNeeded)
|
||||
{
|
||||
@@ -468,7 +422,7 @@ public Action Timer_ChangeMap(Handle hTimer)
|
||||
{
|
||||
g_InChange = false;
|
||||
|
||||
LogMessage("RTV changing map manually");
|
||||
//LogMessage("RTV changing map manually");
|
||||
|
||||
char map[PLATFORM_MAX_PATH];
|
||||
if (GetNextMap(map, sizeof(map)))
|
||||
@@ -523,7 +477,7 @@ public Action Command_DebugRTV(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
int iVotersSteam = 0;
|
||||
int iVoters = 0;
|
||||
|
||||
for (int i=1; i<=MaxClients; i++)
|
||||
{
|
||||
@@ -532,12 +486,11 @@ public Action Command_DebugRTV(int client, int args)
|
||||
if (GetClientIdleTime(i) >= g_Cvar_AFKTime.IntValue)
|
||||
continue;
|
||||
|
||||
if (PM_IsPlayerSteam(i))
|
||||
iVotersSteam++;
|
||||
iVoters++;
|
||||
}
|
||||
}
|
||||
|
||||
int iVotesNeededTotal = RoundToFloor(float(iVotersSteam) * GetConVarFloat(g_Cvar_Steam_Needed));
|
||||
int iVotesNeededTotal = RoundToFloor(float(iVoters) * GetConVarFloat(g_Cvar_Steam_Needed));
|
||||
ReplyToCommand(client, "[RTVE] Currently %d Players needed to start a RTV vote.", iVotesNeededTotal);
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
Reference in New Issue
Block a user