From 1de17daf4826e47328dc7825c1907f1af222bb4a Mon Sep 17 00:00:00 2001 From: jenz Date: Sat, 30 Sep 2023 11:45:13 +0200 Subject: [PATCH] updated the avghour message again to display percentage for rtv correctly --- .../include/rockthevote_extended.inc | 10 +++++ .../scripting/mapchooser_extended_avg.sp | 6 ++- .../scripting/rockthevote_extended_avg.sp | 39 +++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100755 mapchooser_extended/scripting/include/rockthevote_extended.inc diff --git a/mapchooser_extended/scripting/include/rockthevote_extended.inc b/mapchooser_extended/scripting/include/rockthevote_extended.inc new file mode 100755 index 00000000..27105d3a --- /dev/null +++ b/mapchooser_extended/scripting/include/rockthevote_extended.inc @@ -0,0 +1,10 @@ +#if defined _rockthevote_extended_included_ + #endinput +#endif +#define _rockthevote_extended_included_ + +/** +* calls UpdateRTV() +* @returns the players worth of the rtv in percentage +*/ +native int GetRtvPercentage(int client); diff --git a/mapchooser_extended/scripting/mapchooser_extended_avg.sp b/mapchooser_extended/scripting/mapchooser_extended_avg.sp index dee9649c..a401281d 100755 --- a/mapchooser_extended/scripting/mapchooser_extended_avg.sp +++ b/mapchooser_extended/scripting/mapchooser_extended_avg.sp @@ -51,6 +51,7 @@ #include #include #include +#include #pragma semicolon 1 #pragma newdecls required @@ -695,11 +696,12 @@ public Action Command_hours_average(int client, int args) total_votes += GetPlayerWorthRTV_boost_(i); } } - 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 (%i%%)", + 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)", GetAveragePlayerTimeOnServer(), GetAveragePlayerTimeOnServerRTV(), GetPlayerWorthRTV_boost_(client), - RoundToFloor((GetPlayerWorthRTV_boost_(client)/total_votes) * 100)); + RoundToFloor((GetPlayerWorthRTV_boost_(client)/total_votes) * 100), + GetRtvPercentage(client)); return Plugin_Handled; } diff --git a/mapchooser_extended/scripting/rockthevote_extended_avg.sp b/mapchooser_extended/scripting/rockthevote_extended_avg.sp index 6fa9cbf4..90999a9d 100755 --- a/mapchooser_extended/scripting/rockthevote_extended_avg.sp +++ b/mapchooser_extended/scripting/rockthevote_extended_avg.sp @@ -177,6 +177,45 @@ public void OnPlayerChangedTeam(Handle event, const char[] name, bool dontBroadc UpdateRTV(); } +public APLRes AskPluginLoad2(Handle myself, bool late, char [] error, int err_max) +{ + CreateNative("GetRtvPercentage", Native_GetRtvPercentageForClient); + return APLRes_Success; +} + +public int Native_GetRtvPercentageForClient(Handle plugin, int numParams) +{ + int client = GetNativeCell(1); + + if(client > MaxClients || client <= 0) + { + ThrowNativeError(SP_ERROR_NATIVE, "Client is not valid."); + return -1; + } + + if(!IsClientInGame(client)) + { + ThrowNativeError(SP_ERROR_NATIVE, "Client is not in-game."); + return -1; + } + + 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; +} + void UpdateRTV() { int iVotersSteam = 0;