updated the avghour message again to display percentage for rtv correctly

This commit is contained in:
jenz 2023-09-30 11:45:13 +02:00
parent 47085dcacf
commit 1de17daf48
3 changed files with 53 additions and 2 deletions

View File

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

View File

@ -51,6 +51,7 @@
#include <sdktools>
#include <multicolors>
#include <PlayerManager>
#include <rockthevote_extended>
#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;
}

View File

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