added showing percentage worth to both mapvote menu and to rtv messages

This commit is contained in:
jenz 2023-09-29 20:14:21 +02:00
parent 85504bef9b
commit 20ddc26c76
4 changed files with 26 additions and 13 deletions

View File

@ -1369,12 +1369,15 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
int clients[MAXPLAYERS + 1]; int clients[MAXPLAYERS + 1];
int count = 0; 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++) for (int i = 0; i < MaxClients; i++)
{ {
player_mapvote_worth[i] = 0.0; player_mapvote_worth[i] = 0.0;
Format(player_mapvote[i], 128, ""); Format(player_mapvote[i], 128, "");
if (IsValidClient(i) && PM_IsPlayerSteam(i) && !is_bot_player[i]) if (IsValidClient(i) && PM_IsPlayerSteam(i) && !is_bot_player[i])
{ {
GetPlayerWorthRTV_(i);
player_mapvote_worth[i] = GetPlayerWorthRTV_boost_(i);
clients[count] = i; clients[count] = i;
count++; count++;
} }
@ -1715,10 +1718,18 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
{ {
Format(player_mapvote[param1], 128, ""); Format(player_mapvote[param1], 128, "");
static char buffer[255]; static char buffer[255];
GetPlayerWorthRTV_(param1);
float rtv_worth = GetPlayerWorthRTV_boost_(param1); //displaying to the client how much percent his vote is worth.
player_mapvote_worth[param1] = rtv_worth; float total_votes = 0.0;
Format(buffer, sizeof(buffer), "%T", "Vote Nextmap", param1, rtv_worth); for (int i = 0; i < MaxClients; i++)
{
if (IsValidClient(i) && !is_bot_player[i] && PM_IsPlayerSteam(i))
{
total_votes += player_mapvote_worth[i];
}
}
//second parameter shows for example 5.0, last parameter is how much percentage of the entire vote the client decides.
Format(buffer, sizeof(buffer), "%T", "Vote Nextmap", param1, player_mapvote_worth[param1], RoundToFloor((player_mapvote_worth[param1]/total_votes) * 100));
Handle panel = view_as<Handle>(param2); Handle panel = view_as<Handle>(param2);
SetPanelTitle(panel, buffer); SetPanelTitle(panel, buffer);
char PannelText[256] = "Warning: The Position of the Maps are different for each Player."; char PannelText[256] = "Warning: The Position of the Maps are different for each Player.";

View File

@ -297,7 +297,8 @@ void AttemptRTV(int client)
{ {
rtv_percentage_reached = 100; rtv_percentage_reached = 100;
} }
ReplyToCommand(client, "[RTVE] %t", "Already Voted", rtv_percentage_reached, "%", rtv_worth); ReplyToCommand(client, "[RTVE] %t", "Already Voted", rtv_percentage_reached, rtv_worth,
RoundToFloor((GetPlayerWorthRTV_(client) / float(g_VotesNeeded)) * 100));
return; return;
} }
@ -323,7 +324,8 @@ void AttemptRTV(int client)
{ {
rtv_percentage_reached = 100; rtv_percentage_reached = 100;
} }
PrintToChatAll("[RTVE] %t", "RTV Requested", name, rtv_percentage_reached, "%", rtv_worth); PrintToChatAll("[RTVE] %t", "RTV Requested", name, rtv_percentage_reached, rtv_worth,
RoundToFloor((GetPlayerWorthRTV_(client) / float(g_VotesNeeded)) * 100));
if (Votes >= g_VotesNeeded) if (Votes >= g_VotesNeeded)
{ {

View File

@ -2,8 +2,8 @@
{ {
"Vote Nextmap" "Vote Nextmap"
{ {
"#format" "{1:.1f}" "#format" "{1:.1f},{2:i}"
"en" "Vote for the next map! ({1} Mapvote Boost)" "en" "Vote for the next map! ({1} Mapvote Boost) ({2}%%)"
} }
"Nextmap Voting Started" "Nextmap Voting Started"

View File

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