changing map chooser again to use numbers of votes instead of percentages

This commit is contained in:
jenz 2025-02-23 13:15:52 +01:00
parent dcbfe513d5
commit 239d53c57b
5 changed files with 94 additions and 228 deletions

View File

@ -151,7 +151,6 @@ int g_iPlayerAFKTime;
int g_NominateCount = 0;
int g_NominateReservedCount = 0;
int g_iInterval;
float player_mapvote_worth[MAXPLAYERS + 1];
char player_mapvote[MAXPLAYERS + 1][PLATFORM_MAX_PATH];
MapChange g_ChangeTime;
@ -514,7 +513,6 @@ public void OnMapStart()
int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10;
ServerCommand("sm_cvar mp_chattime %i", total_time); //prevents map switching supposedly.
ServerCommand("sm_cvar sm_vote_progress_hintbox 1"); //yeah its cheesy but does the job.
g_iInterval = 0;
static char folder[64];
GetGameFolderName(folder, sizeof(folder));
@ -617,7 +615,6 @@ public void OnMapEnd()
int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10;
ServerCommand("sm_cvar mp_chattime %i", total_time);
ServerCommand("sm_cvar sm_vote_progress_hintbox 1"); //yeah its cheesy but does the job.
g_iInterval = 0;
g_HasVoteStarted = false;
g_WaitingForVote = false;
@ -682,7 +679,6 @@ public void OnClientPutInServer(int client)
public void OnClientDisconnect(int client)
{
is_bot_player[client] = false;
player_mapvote_worth[client] = 0.0;
Format(player_mapvote[client], 128, "");
int index = FindValueInArray(g_NominateOwners, client);
@ -753,32 +749,10 @@ public Action Command_ReloadMaps(int client, int args)
public Action Command_hours_average(int client, int args)
{
float total_votes = 0.0;
for (int i = 0; i < MaxClients; i++)
{
if (IsValidClient(i) && !is_bot_player[i] && PM_IsPlayerSteam(i))
{
GetPlayerWorthRTV_(i);
float nominate_worth = GetPlayerWorthRTV_boost_(i);
if (nominate_worth < 1.0)
{
nominate_worth = 1.0;
}
total_votes += nominate_worth;
}
}
float nominate_worth = GetPlayerWorthRTV_boost_(client);
if (nominate_worth < 1.0)
{
nominate_worth = 1.0;
}
CReplyToCommand(client, "Average hour count for nominations is: %i \nAverage hour count for mapvote and rtv boost is: %i \nYour mapvote and rtv boost is %0.1f \n(%i%% mapvote) (%i%% rtv)",
int nominate_worth = GetPlayerWorthRTV_boost_(client);
CReplyToCommand(client, "Average hour count is: %i \nYour mapvote and rtv boost is: %i",
GetAveragePlayerTimeOnServer(),
GetAveragePlayerTimeOnServerRTV(),
nominate_worth,
RoundToFloor((nominate_worth/total_votes) * 100),
GetRtvPercentage(client));
nominate_worth);
return Plugin_Handled;
}
@ -1172,11 +1146,7 @@ public Handle get_most_nominated_maps(bool create_next_vote)
}
else
{
int nominate_worth = RoundToFloor(GetPlayerWorthRTV_boost_(i));
if (nominate_worth < 1)
{
nominate_worth = 1;
}
int nominate_worth = GetPlayerWorthRTV_boost_(i);
nominate_count_for_particular_map += nominate_worth;
}
sm.SetValue(map_iteration, nominate_count_for_particular_map, true);
@ -1328,7 +1298,6 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
g_ChangeTime = when;
ServerCommand("sm_cvar sm_vote_progress_hintbox 0"); //yeah its cheesy but does the job.
g_iInterval = GetConVarInt(g_Cvar_VoteDuration);
CreateTimer(1.0, Timer_Countdown, _, TIMER_REPEAT);
@ -1535,24 +1504,16 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
MenuShufflePerClient(g_VoteMenu, MenuRandomShuffleStart, GetMenuItemCount(g_VoteMenu) - MenuRandomShuffleStop);
//VoteMenuToAll(g_VoteMenu, voteDuration);
//2023 excluding nosteamers and autismbots.
int clients[MAXPLAYERS + 1];
int count = 0;
//here we pick clients to show the vote to, we dont show it to autismbots and nosteamers.
for (int i = 0; i < MaxClients; i++)
{
player_mapvote_worth[i] = 0.0;
Format(player_mapvote[i], 128, "");
if (IsValidClient(i) && PM_IsPlayerSteam(i) && !is_bot_player[i])
//2023 excluding autismbots.
if (IsValidClient(i) && !is_bot_player[i])
{
GetPlayerWorthRTV_(i);
float nominate_worth = GetPlayerWorthRTV_boost_(i);
if (nominate_worth < 1.0)
{
nominate_worth = 1.0;
}
player_mapvote_worth[i] = nominate_worth;
clients[count] = i;
count++;
}
@ -1575,26 +1536,26 @@ public Action Timer_Countdown(Handle timer)
if (g_iInterval <= 0)
return Plugin_Stop;
float most_voted[3];
int most_voted[3];
char most_voted_map[3][PLATFORM_MAX_PATH];
for (int j = 0; j < 3; j++)
{
float max_count = 0.0;
int max_count = 0;
StringMap sm = new StringMap();
char picked_map[PLATFORM_MAX_PATH];
for (int i = 0; i < MaxClients; i++)
{
if (IsValidClient(i) && !StrEqual(player_mapvote[i], "") && !is_bot_player[i] && PM_IsPlayerSteam(i))
if (IsValidClient(i) && !StrEqual(player_mapvote[i], "") && !is_bot_player[i] )
{
if (StrEqual(player_mapvote[i], most_voted_map[0]) || StrEqual(player_mapvote[i], most_voted_map[1]) ||
StrEqual(player_mapvote[i], most_voted_map[2]))
{
continue;
}
float value = 0.0;
int value = 0;
sm.GetValue(player_mapvote[i], value);
value += player_mapvote_worth[i];
value += GetPlayerWorthRTV_boost_(i);
sm.SetValue(player_mapvote[i], value, true);
if (value >= max_count)
{
@ -1608,52 +1569,50 @@ public Action Timer_Countdown(Handle timer)
delete sm;
}
float total_votes = 0.0;
float voted_so_far = 0.0;
int total_votes = 0;
int voted_so_far = 0;
for (int i = 0; i < MaxClients; i++)
{
if (IsValidClient(i) && !is_bot_player[i] && PM_IsPlayerSteam(i))
if (IsValidClient(i) && !is_bot_player[i])
{
total_votes += player_mapvote_worth[i];
//LogMessage("client: %N player_mapvote_worth i: %f", i, player_mapvote_worth[i]);
total_votes += GetPlayerWorthRTV_boost_(i);
if (!StrEqual(player_mapvote[i], ""))
{
voted_so_far += player_mapvote_worth[i];
voted_so_far += GetPlayerWorthRTV_boost_(i);
}
}
}
//why on earth is %%%s needed for formatting it to show a % lmao. just %s, "%" or %% on their own dont work.
if (strlen(most_voted_map[2]) > 0)
{
//displaying 3 most voted maps
PrintHintTextToAll("Votes: %i/100%%%s, %ds left\n1. %s: (%i%%%s)\n2. %s: (%i%%%s)\n3. %s: (%i%%%s)", RoundToFloor((voted_so_far/total_votes) * 100),
"%", g_iInterval, most_voted_map[0], RoundToFloor((most_voted[0]/total_votes) * 100), "%", most_voted_map[1], RoundToFloor((most_voted[1]/total_votes) * 100),
"%", most_voted_map[2], RoundToFloor((most_voted[2]/total_votes) * 100), "%");
PrintHintTextToAll("Votes: %i/%i, %ds left\n1. %s: (%i/%i)\n2. %s: (%i/%i)\n3. %s: (%i/%i)", voted_so_far, total_votes,
"%", g_iInterval, most_voted_map[0], most_voted[0], total_votes, most_voted_map[1], most_voted[1], total_votes,
most_voted_map[2], most_voted[2], total_votes);
}
else if (strlen(most_voted_map[1]) > 0)
{
//displaying 2 most voted maps
PrintHintTextToAll("Votes: %i/100%%%s, %ds left\n1. %s: (%i%%%s)\n2. %s: (%i%%%s)", RoundToFloor((voted_so_far/total_votes) * 100), "%", g_iInterval,
most_voted_map[0], RoundToFloor((most_voted[0]/total_votes) * 100), "%", most_voted_map[1], RoundToFloor((most_voted[1]/total_votes) * 100), "%");
PrintHintTextToAll("Votes: %i/%i, %ds left\n1. %s: (%i/%i)\n2. %s: (%i/%i)", voted_so_far, total_votes, g_iInterval,
most_voted_map[0], most_voted[0], total_votes, most_voted_map[1], most_voted[1], total_votes);
}
else if (strlen(most_voted_map[0]) > 0)
{
//displaying the most voted map
PrintHintTextToAll("Votes: %i/100%%%s, %ds left\n1. %s: (%i%%%s)", RoundToFloor((voted_so_far/total_votes) * 100),
"%", g_iInterval, most_voted_map[0], RoundToFloor((most_voted[0]/total_votes) * 100), "%");
PrintHintTextToAll("Votes: %i/%i, %ds left\n1. %s: (%i/%i)", voted_so_far, total_votes,
g_iInterval, most_voted_map[0], most_voted[0], total_votes);
}
else
{
//displaying just the votecount and vote duration remaining
PrintHintTextToAll("Votes: %i/100%%%s, %ds left", RoundToFloor((voted_so_far/total_votes) * 100), "%", g_iInterval);
PrintHintTextToAll("Votes: %i/%i, %ds left", voted_so_far, total_votes, g_iInterval);
}
g_iInterval--;
return Plugin_Continue;
}
public void Handler_VoteFinishedGeneric(char[] map,
float num_votes,
float map_votes)
int num_votes,
int map_votes)
{
Call_StartForward(g_MapVoteEndForward);
Call_PushString(map);
@ -1681,7 +1640,7 @@ public void Handler_VoteFinishedGeneric(char[] map,
if(fraglimit)
SetConVarInt(g_Cvar_Fraglimit, fraglimit + GetConVarInt(g_Cvar_ExtendFragStep));
PrintToChatAll("The current map has been extended. (Received %i%s of votes)", RoundToFloor((map_votes /num_votes)*100.0), "%");
PrintToChatAll("The current map has been extended. (Received %i/%i of votes)", map_votes, num_votes);
LogAction(-1, -1, "Voting for next map has finished. The current map has been extended.");
CPrintToChatAll("[MCE] Available Extends: %d", GetConVarInt(g_Cvar_Extend) - g_Extends);
@ -1698,7 +1657,7 @@ public void Handler_VoteFinishedGeneric(char[] map,
}
else if(strcmp(map, VOTE_DONTCHANGE, false) == 0)
{
PrintToChatAll("[MCE] Current map continues! The Vote has spoken! (Received %i%s of votes)", RoundToFloor((map_votes /num_votes)*100.0), "%");
PrintToChatAll("[MCE] Current map continues! The Vote has spoken! (Received %i/%i of votes)", map_votes, num_votes);
LogAction(-1, -1, "Voting for next map has finished. 'No Change' was the winner");
g_RunoffCount = 0;
@ -1731,23 +1690,17 @@ public void Handler_VoteFinishedGeneric(char[] map,
g_MapVoteCompleted = true;
//checking on MapStart and MapEnd is not good enough. Players are not considered alive and on teams at those points in time.
//therefore instead applying the bool here after the mapvote completed.
/*
if(InternalAreRestrictionsActive(false))
g_SaveCDOnMapEnd = true;
else
g_SaveCDOnMapEnd = false;
*/
g_SaveCDOnMapEnd = true;
//PrintToChatAll("map: %s", map);
if (g_ChangeTime == MapChange_MapEnd)
{
CPrintToChatAll("[MCE] %t", "Extend Voting Failed", RoundToFloor((map_votes /num_votes)*100.0));
CPrintToChatAll("[MCE] %t", "Extend Voting Failed", map_votes, num_votes);
g_MapVoteCompleted = false; //this was only the extend or dont extend vote, still need actual mapvote.
}
else
{
CPrintToChatAll("[MCE] %t", "Nextmap Voting Finished", map, RoundToFloor((map_votes /num_votes)*100.0));
CPrintToChatAll("[MCE] %t", "Nextmap Voting Finished", map, map_votes, num_votes);
LogAction(-1, -1, "Voting for next map has finished. Nextmap: %s.", map);
}
}
@ -1761,9 +1714,9 @@ public void Handler_MapVoteFinished(Handle menu,
const int[][] item_info)
{
g_iInterval = 1; //we display it shortly after finishing
ServerCommand("sm_cvar sm_vote_progress_hintbox 1"); //yeah its cheesy but does the job.
//reweighting votes
StringMap sm = new StringMap();
for (int i = 0; i < num_clients; i++)
{
int client = client_info[i][0];
@ -1780,33 +1733,28 @@ public void Handler_MapVoteFinished(Handle menu,
break;
}
}
float value = 0.0;
sm.GetValue(map, value);
float nominate_worth = GetPlayerWorthRTV_boost_(client);
if (nominate_worth < 1.0)
{
nominate_worth = 1.0;
}
value += nominate_worth;
int value = 0;
sm.GetValue(map, value);
value += GetPlayerWorthRTV_boost_(client);
sm.SetValue(map, value, true);
}
}
//ordering stringmap by voteweight
float[] weighted_votes = new float[num_items];
int[] weighted_votes = new int[num_items];
char[][] weighted_maps = new char[num_items][PLATFORM_MAX_PATH];
for (int i = 0; i < num_items; i++)
{
StringMapSnapshot keys = sm.Snapshot();
float max_count = 0.0;
int max_count = 0;
char picked_map[PLATFORM_MAX_PATH];
for (int j = 0; j < keys.Length; j++)
{
int size = keys.KeyBufferSize(j);
char[] buffer = new char[size];
keys.GetKey(j, buffer, size);
float value = 0.0;
int value = 0;
sm.GetValue(buffer, value);
//first selection has most votes, second selection second most etc etc
@ -1823,18 +1771,11 @@ public void Handler_MapVoteFinished(Handle menu,
}
delete sm;
float total_votes = 0.0;
for (int i = 0; i < MaxClients; i++)
{
if (IsValidClient(i) && !is_bot_player[i] && PM_IsPlayerSteam(i))
{
total_votes += player_mapvote_worth[i];
}
}
// Implement revote logic - Only run this` block if revotes are enabled and this isn't the last revote'
//LogMessage("Mapchooser_extended_avg Handler_MapVoteFinished.");
int required_percent = GetConVarInt(g_Cvar_RunOffPercent);
int most_voted_map_percentage = RoundToFloor((weighted_votes[0] / total_votes) * 100);
int most_voted_map_percentage = ((weighted_votes[0] / num_votes) * 100);
if(GetConVarBool(g_Cvar_RunOff) && g_RunoffCount < GetConVarInt(g_Cvar_MaxRunOffs) && num_items > 1 && g_ChangeTime != MapChange_MapEnd &&
(weighted_votes[0] == weighted_votes[1] || most_voted_map_percentage < required_percent))
{
@ -1896,7 +1837,7 @@ public void Handler_MapVoteFinished(Handle menu,
g_WaitingForVote = false;
//LogMessage("Mapchooser_extended_avg no revote needed, continue as normal.");
// No revote needed, continue as normal.
Handler_VoteFinishedGeneric(weighted_maps[0], total_votes, weighted_votes[0]);
Handler_VoteFinishedGeneric(weighted_maps[0], num_votes, weighted_votes[0]); //change again
}
public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int param2)
@ -1927,23 +1868,15 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
Format(player_mapvote[param1], 128, "");
static char buffer[255];
//displaying to the client how much percent his vote is worth.
float total_votes = 0.0;
for (int i = 0; i < MaxClients; i++)
{
if (IsValidClient(i) && !is_bot_player[i] && PM_IsPlayerSteam(i))
{
total_votes += player_mapvote_worth[i];
}
}
//displaying to the client how much his vote is worth.
//second parameter shows for example 5.0, last parameter is how much percentage of the entire vote the client decides.
if (g_ChangeTime == MapChange_MapEnd)
{
Format(buffer, sizeof(buffer), "%T", "Vote Extend", param1, player_mapvote_worth[param1], RoundToFloor((player_mapvote_worth[param1]/total_votes) * 100));
Format(buffer, sizeof(buffer), "%T", "Vote Extend", param1, GetPlayerWorthRTV_boost_(param1));
}
else
{
Format(buffer, sizeof(buffer), "%T", "Vote Nextmap", param1, player_mapvote_worth[param1], RoundToFloor((player_mapvote_worth[param1]/total_votes) * 100));
Format(buffer, sizeof(buffer), "%T", "Vote Nextmap", param1, GetPlayerWorthRTV_boost_(param1));
}
Handle panel = view_as<Handle>(param2);
SetPanelTitle(panel, buffer);
@ -2036,7 +1969,6 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
g_HasVoteStarted = false;
g_RunoffCount = 0;
g_iInterval = 1; //we display it shortly after finishing
ServerCommand("sm_cvar sm_vote_progress_hintbox 1"); //yeah its cheesy but does the job.
}
}
return 0;
@ -3209,7 +3141,6 @@ stock int InternalGetMapTimeRestriction(const char[] map)
public void OnClientPostAdminCheck(int client)
{
is_bot_player[client] = false;
player_mapvote_worth[client] = 0.0;
Format(player_mapvote[client], 128, "");
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
@ -3242,7 +3173,7 @@ stock int InternalGetMapPlayerRestriction(const char[] map)
for (int client = 1; client <= MaxClients; client++)
{
if (IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client) && !IsClientSourceTV(client) && !is_bot_player[client]
&& PM_IsPlayerSteam(client))
)
{
NumPlayers++;
}

View File

@ -169,7 +169,6 @@ public void sql_select_hiding_unavailable_maps(int client)
char query[255];
char steam_auth[64];
GetClientAuthId(client, AuthId_Steam2, steam_auth, sizeof(steam_auth));
//we have way too many dbs, just adding this to unloze_race_timer
Format(query, sizeof(query), "SELECT is_ignoring FROM `mapchooser_hide_unavailable` where steam_auth = '%s'", steam_auth);
g_dDatabase.Query(SQL_OnQueryCompleted_ignoring, query, GetClientSerial(client));
}
@ -501,7 +500,7 @@ public Action Command_Removemap(int client, int args)
GetCmdArg(1, mapname, sizeof(mapname));
// int status;
if(/*!GetTrieValue(g_mapTrie, mapname, status)*/!IsMapValid(mapname))
if(!IsMapValid(mapname))
{
CReplyToCommand(client, "%t", "Map was not found", mapname);
AttemptAdminRemoveMap(client, mapname);
@ -669,7 +668,6 @@ public Action Command_Nominate(int client, int args)
static char mapname[PLATFORM_MAX_PATH];
GetCmdArg(1, mapname, sizeof(mapname));
int status;
if(!GetTrieValue(g_mapTrie, mapname, status))
{
@ -773,11 +771,7 @@ public Action Command_Nominate(int client, int args)
if(result == Nominate_Added)
{
int nominate_worth = RoundToFloor(GetPlayerWorthRTV_boost_(client));
if (nominate_worth < 1)
{
nominate_worth = 1;
}
int nominate_worth = GetPlayerWorthRTV_boost_(client);
PrintToChatAll("[NE] %t", "Map Nominated", name, mapname, nominate_worth);
}
else if(result == Nominate_Replaced)
@ -850,12 +844,7 @@ void AttemptNominate(int client, const char[] filter = "")
Menu menu = g_MapMenu;
menu = BuildMapMenu(filter, client);
GetPlayerWorthRTV_(client);
int nominate_worth = RoundToFloor(GetPlayerWorthRTV_boost_(client));
if (nominate_worth < 1)
{
nominate_worth = 1;
}
int nominate_worth = GetPlayerWorthRTV_boost_(client);
SetMenuTitle(menu, "%T", "Nominate Title", client, nominate_worth);
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}
@ -946,11 +935,8 @@ bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "")
}
else
{
int nominate_worth = RoundToFloor(GetPlayerWorthRTV_boost_(owner));
if (nominate_worth < 1)
{
nominate_worth = 1;
}
int nominate_worth = GetPlayerWorthRTV_boost_(owner);
//atm everybody just has equal voting again, so this is just += 1
nominate_count_for_particular_map += nominate_worth;
}
sm.SetValue(map, nominate_count_for_particular_map, true);
@ -1207,11 +1193,7 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
if(result == Nominate_Added)
{
int nominate_worth = RoundToFloor(GetPlayerWorthRTV_boost_(param1));
if (nominate_worth < 1)
{
nominate_worth = 1;
}
int nominate_worth = GetPlayerWorthRTV_boost_(param1);
PrintToChatAll("[NE] %t", "Map Nominated", name, map, nominate_worth);
}
else if(result == Nominate_Replaced)

View File

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

View File

@ -2,14 +2,14 @@
{
"Vote Nextmap"
{
"#format" "{1:.1f},{2:i}"
"en" "Vote for the next map! ({1} Mapvote Boost) ({2}%%)"
"#format" "{1:i}"
"en" "Vote for the next map! ({1} Mapvote Boost)"
}
"Vote Extend"
{
"#format" "{1:.1f},{2:i}"
"en" "Vote for the map extend! ({1} Mapvote Boost) ({2}%%)"
"#format" "{1:i}"
"en" "Vote for the map extend! ({1} Mapvote Boost)"
}
"Nextmap Voting Started"
@ -19,14 +19,14 @@
"Nextmap Voting Finished"
{
"#format" "{1:s},{2:i}"
"en" "Map voting has finished. The next map will be {1}. (Received {2}%% of votes)"
"#format" "{1:s},{2:i},{3:i}"
"en" "Map voting has finished. The next map will be {1}. (Received {2}/{3} of votes)"
}
"Extend Voting Failed"
{
"#format" "{1:i}"
"en" "Extend voting finished. The map was not extended. (Received {1}%% of votes)"
"#format" "{1:i},{2:i}"
"en" "Extend voting finished. The map was not extended. (Received {1}/{2} of votes)"
}
"Current Map Extended"
@ -47,8 +47,8 @@
"Current Map Stays"
{
"#format" "{1:i}"
"en" "Current map continues! The Vote has spoken! (Received {1}%% of votes)"
"#format" "{1:i},{2:i}"
"en" "Current map continues! The Vote has spoken! (Received {1}/{2} of votes)"
}
"Changed Next Map"

View File

@ -22,8 +22,8 @@
"Already Voted"
{
"#format" "{1:d},{2:.1f},{3:i}"
"en" "You have already voted to Rock the Vote. ({1}%% RTV reached. ({2} RTV boost) ({3}%%)"
"#format" "{1:i},{2:i},{3:i}"
"en" "You have already voted to Rock the Vote. ({1}/{2} Votes. ({3} client RTV boost))"
}
"Wait Before Revoting"
@ -44,8 +44,8 @@
"RTV Requested"
{
"#format" "{1:s},{2:d},{3:.1f},{4:d}"
"en" "{1} wants to rock the vote. ({2}%% RTV reached) ({3} RTV boost) ({4}%%)"
"#format" "{1:s},{2:d},{3:i},{4:i}"
"en" "{1} wants to rock the vote. ({2}/{3} RTV reached) ({4} RTV boost)."
}
"RTV Undone"