added support for average hour to rtv
This commit is contained in:
parent
44e43e5d8c
commit
8bbb937f6f
@ -7,3 +7,13 @@
|
|||||||
* @returns the average playtime of all connected players excluding autism bots, fakeclients, AFKS and nosteamers
|
* @returns the average playtime of all connected players excluding autism bots, fakeclients, AFKS and nosteamers
|
||||||
*/
|
*/
|
||||||
native int GetAveragePlayerTimeOnServer();
|
native int GetAveragePlayerTimeOnServer();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns the average playtime of all connected players for rtv, excluding autism bots and fakeclients.
|
||||||
|
*/
|
||||||
|
native int GetAveragePlayerTimeOnServerRTV();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns the players worth in connected hours for the rtv
|
||||||
|
*/
|
||||||
|
native int GetPlayerWorthRTV_(int client);
|
||||||
|
@ -15,6 +15,9 @@ char g_cTimeRecords[100][128];
|
|||||||
int g_iPlayerTimeServer[MAXPLAYERS + 1];
|
int g_iPlayerTimeServer[MAXPLAYERS + 1];
|
||||||
int g_iPlayerAFKTime;
|
int g_iPlayerAFKTime;
|
||||||
int g_iPlayerCount_excludeSpec;
|
int g_iPlayerCount_excludeSpec;
|
||||||
|
int g_iPlayerRTVCapacity;
|
||||||
|
|
||||||
|
float g_fPlayerRTVWorth[MAXPLAYERS + 1];
|
||||||
|
|
||||||
public Plugin myinfo =
|
public Plugin myinfo =
|
||||||
{
|
{
|
||||||
@ -98,6 +101,11 @@ public void OnPluginStart()
|
|||||||
g_iPlayerCount_excludeSpec = cvar1.IntValue;
|
g_iPlayerCount_excludeSpec = cvar1.IntValue;
|
||||||
delete cvar1;
|
delete cvar1;
|
||||||
//g_hTimer_avg_hour_count = CreateTimer(1800.0, log_average_hour_count, _, TIMER_REPEAT);
|
//g_hTimer_avg_hour_count = CreateTimer(1800.0, log_average_hour_count, _, TIMER_REPEAT);
|
||||||
|
|
||||||
|
ConVar cvar2;
|
||||||
|
HookConVarChange((cvar2 = CreateConVar("sm_rtv_avg_capacity", "5", "The capacity for how many times the average a players rtv can be worth.")), Cvar_playerRTVAverageCap);
|
||||||
|
g_iPlayerRTVCapacity = cvar2.IntValue;
|
||||||
|
delete cvar2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -126,9 +134,17 @@ public void Cvar_playerExcludeSpec(ConVar convar, const char[] oldValue, const c
|
|||||||
g_iPlayerCount_excludeSpec = convar.IntValue;
|
g_iPlayerCount_excludeSpec = convar.IntValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Cvar_playerRTVAverageCap(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||||
|
{
|
||||||
|
g_iPlayerRTVCapacity = convar.IntValue;
|
||||||
|
}
|
||||||
|
|
||||||
public APLRes AskPluginLoad2(Handle myself, bool late, char [] error, int err_max)
|
public APLRes AskPluginLoad2(Handle myself, bool late, char [] error, int err_max)
|
||||||
{
|
{
|
||||||
CreateNative("GetAveragePlayerTimeOnServer", Native_GetAveragePlayerActiveTimeServer);
|
CreateNative("GetAveragePlayerTimeOnServer", Native_GetAveragePlayerActiveTimeServer);
|
||||||
|
CreateNative("GetAveragePlayerTimeOnServerRTV", Native_GetAveragePlayerActiveTimeServerRTV);
|
||||||
|
CreateNative("GetPlayerWorthRTV_", Native_GetPlayerWorthRTV);
|
||||||
|
CreateNative("GetPlayerWorthRTV_boost_", Native_GetPlayerWorthRTV_boost);
|
||||||
return APLRes_Success;
|
return APLRes_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,6 +186,84 @@ public int Native_GetAveragePlayerActiveTimeServer(Handle plugin, int numParams)
|
|||||||
{
|
{
|
||||||
return GetAveragePlayerActiveTimeServer();
|
return GetAveragePlayerActiveTimeServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int Native_GetAveragePlayerActiveTimeServerRTV(Handle plugin, int numParams)
|
||||||
|
{
|
||||||
|
return GetAveragePlayerActiveTimeServerRTV();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Native_GetPlayerWorthRTV_boost(Handle plugin, int numParams)
|
||||||
|
{
|
||||||
|
int client = GetNativeCell(1);
|
||||||
|
if(client > MaxClients || client <= 0)
|
||||||
|
{
|
||||||
|
ThrowNativeError(SP_ERROR_NATIVE, "Client is not valid.");
|
||||||
|
return view_as<int>(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!IsClientInGame(client))
|
||||||
|
{
|
||||||
|
ThrowNativeError(SP_ERROR_NATIVE, "Client is not in-game.");
|
||||||
|
return view_as<int>(-1);
|
||||||
|
}
|
||||||
|
return view_as<int>(g_fPlayerRTVWorth[client]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Native_GetPlayerWorthRTV(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;
|
||||||
|
}
|
||||||
|
return GetPlayerWorthRTV(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetPlayerWorthRTV(int client)
|
||||||
|
{
|
||||||
|
int avg = GetAveragePlayerActiveTimeServerRTV();
|
||||||
|
if (g_iPlayerTimeServer[client] <= avg || avg == 0 || is_bot_player[client])
|
||||||
|
{
|
||||||
|
g_fPlayerRTVWorth[client] = 1.0;
|
||||||
|
return avg;
|
||||||
|
}
|
||||||
|
if ((g_iPlayerTimeServer[client] / avg) > g_iPlayerRTVCapacity)
|
||||||
|
{
|
||||||
|
g_fPlayerRTVWorth[client] = float(g_iPlayerRTVCapacity);
|
||||||
|
return avg * g_iPlayerRTVCapacity;
|
||||||
|
}
|
||||||
|
g_fPlayerRTVWorth[client] = float(g_iPlayerTimeServer[client] / avg);
|
||||||
|
return avg * (g_iPlayerTimeServer[client] / avg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetAveragePlayerActiveTimeServerRTV()
|
||||||
|
{
|
||||||
|
//for rockthevote average we include spectators and afks. just not fakes, nosteamers and autismbots, thats why a different function is made.
|
||||||
|
int total_hours = 0;
|
||||||
|
int total_players = 0;
|
||||||
|
for (int i = 0; i < MaxClients; i++)
|
||||||
|
{
|
||||||
|
if (IsValidClient(i) && !IsFakeClient(i) && !IsClientSourceTV(i) && !is_bot_player[i] && PM_IsPlayerSteam(i))
|
||||||
|
{
|
||||||
|
total_hours += g_iPlayerTimeServer[i];
|
||||||
|
total_players++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (total_hours == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return total_hours / total_players;
|
||||||
|
}
|
||||||
|
|
||||||
public void OnPluginEnd()
|
public void OnPluginEnd()
|
||||||
{
|
{
|
||||||
if (g_h_time_activity != null)
|
if (g_h_time_activity != null)
|
||||||
@ -202,6 +296,7 @@ public void OnClientPostAdminCheck(int client)
|
|||||||
{
|
{
|
||||||
GetClientAuthId(client, AuthId_Steam2, g_csSID[client], sizeof(g_csSID[]));
|
GetClientAuthId(client, AuthId_Steam2, g_csSID[client], sizeof(g_csSID[]));
|
||||||
is_bot_player[client] = false;
|
is_bot_player[client] = false;
|
||||||
|
g_fPlayerRTVWorth[client] = 0.0;
|
||||||
g_iPlayerTimeServer[client] = 0;
|
g_iPlayerTimeServer[client] = 0;
|
||||||
if(!IsValidClient(client) || IsFakeClient(client))
|
if(!IsValidClient(client) || IsFakeClient(client))
|
||||||
return;
|
return;
|
||||||
@ -294,6 +389,7 @@ public void OnClientDisconnect(int client)
|
|||||||
{
|
{
|
||||||
Format(g_csSID[client], sizeof(g_csSID[]), "");
|
Format(g_csSID[client], sizeof(g_csSID[]), "");
|
||||||
is_bot_player[client] = false;
|
is_bot_player[client] = false;
|
||||||
|
g_fPlayerRTVWorth[client] = 0.0;
|
||||||
g_iPlayerTimeServer[client] = 0;
|
g_iPlayerTimeServer[client] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user