added rtv boost and changed tier display slightly
This commit is contained in:
parent
e00711eedf
commit
76c110f5eb
@ -1,6 +1,6 @@
|
||||
#pragma semicolon 1
|
||||
#define PLUGIN_AUTHOR "jenz"
|
||||
#define PLUGIN_VERSION "1.2"
|
||||
#define PLUGIN_VERSION "1.4"
|
||||
#include <sourcemod>
|
||||
#include <cstrike>
|
||||
#include <PlayerManager>
|
||||
@ -17,6 +17,7 @@ int g_iPlayerAFKTime;
|
||||
int g_iPlayerCount_excludeSpec;
|
||||
int g_iPlayerRTVCapacity;
|
||||
int g_iAvgHour_Contribution_per_player;
|
||||
int g_iRtvBoost_tier;
|
||||
int g_iPlayerTier[MAXPLAYERS + 1];
|
||||
|
||||
StringMap g_GroupOverrides; // group name -> comma-separated override list
|
||||
@ -176,6 +177,11 @@ public void OnPluginStart()
|
||||
HookConVarChange((cvar3 = CreateConVar("sm_avg_hour_contribution_per_player", "5000", "How many hours maximum each player can contribute to averagehours")), Cvar_AverageHourContribution);
|
||||
g_iAvgHour_Contribution_per_player = cvar3.IntValue;
|
||||
delete cvar3;
|
||||
|
||||
ConVar cvar4;
|
||||
HookConVarChange((cvar4 = CreateConVar("sv_rtv_boost_tier", "4", "which tier for giving the rtv/mapvote/nominations boost")), Cvar_RTVBoostTier);
|
||||
g_iRtvBoost_tier = cvar4.IntValue;
|
||||
delete cvar3;
|
||||
}
|
||||
|
||||
public Action UpdateForward(Handle timer)
|
||||
@ -210,6 +216,11 @@ public void Cvar_AverageHourContribution(ConVar convar, const char[] oldValue, c
|
||||
g_iAvgHour_Contribution_per_player = convar.IntValue;
|
||||
}
|
||||
|
||||
public void Cvar_RTVBoostTier(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
g_iRtvBoost_tier = convar.IntValue;
|
||||
}
|
||||
|
||||
public APLRes AskPluginLoad2(Handle myself, bool late, char [] error, int err_max)
|
||||
{
|
||||
CreateNative("GetAveragePlayerTimeOnServer", Native_GetAveragePlayerActiveTimeServer);
|
||||
@ -280,6 +291,12 @@ public int Native_GetPlayerWorthRTV_boost(Handle plugin, int numParams)
|
||||
}
|
||||
|
||||
int avg = GetAveragePlayerActiveTimeServer();
|
||||
//give tier the rtv/nomination/mapvote boost
|
||||
if (g_iPlayerTier[client] >= g_iRtvBoost_tier)
|
||||
{
|
||||
return g_iPlayerRTVCapacity;
|
||||
}
|
||||
|
||||
if (g_iPlayerTimeServer[client] <= avg || avg == 0 || is_bot_player[client] || IsFakeClient(client))
|
||||
{
|
||||
return 1;
|
||||
@ -415,11 +432,120 @@ public void SQL_OnQueryCompletedTimeServer(Database db, DBResultSet results, con
|
||||
if (g_iPlayerTier[client] == -1)
|
||||
{
|
||||
SetPlayerTier(client);
|
||||
SetTierRewards(client);
|
||||
if (g_iPlayerTier[client] > 0)
|
||||
{
|
||||
WritePlayerTierToFile(client); //checks if all tiers have to be written
|
||||
}
|
||||
}
|
||||
else if (check_if_client_new_tier(client))
|
||||
else if (check_if_client_new_tier(client)) //called every 10 minutes to fill new times from DB
|
||||
{
|
||||
SetPlayerTier(client);
|
||||
WritePlayerTierToFile(client); //write only the new tier to the file at the end.
|
||||
}
|
||||
}
|
||||
|
||||
public void WritePlayerTierToFile(int client)
|
||||
{
|
||||
char sPath[PLATFORM_MAX_PATH];
|
||||
BuildPath(Path_SM, sPath, sizeof(sPath), "configs/admins_simple.ini");
|
||||
|
||||
// --- Read entire file into memory ---
|
||||
File f = OpenFile(sPath, "r");
|
||||
if (!f)
|
||||
{
|
||||
LogError("WritePlayerTierToFile: failed to open %s for reading", sPath);
|
||||
return;
|
||||
}
|
||||
|
||||
bool foundSeparator = false;
|
||||
//always write the steamIDs as steamID 2 format.
|
||||
char sSID[64];
|
||||
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
|
||||
bool write_all_tiers = true;
|
||||
bool write_newest_tier = false;
|
||||
|
||||
char line[256];
|
||||
while (f.ReadLine(line, sizeof(line)))
|
||||
{
|
||||
int len = strlen(line);
|
||||
while (len > 0 && (line[len-1] == '\n' || line[len-1] == '\r'))
|
||||
line[--len] = '\0';
|
||||
|
||||
if (StrEqual(line, "//here begins the unloze_play_time plugin tiers", false))
|
||||
{
|
||||
foundSeparator = true;
|
||||
continue;
|
||||
}
|
||||
if (!foundSeparator)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Each line looks like: "STEAM_0:0:12345" "@tier3"
|
||||
// Extract steam ID and tier number
|
||||
char steamid[65];
|
||||
char group[64];
|
||||
|
||||
int pos = 1; //skip opening quote
|
||||
int sidStart = pos;
|
||||
while (line[pos] != '"')
|
||||
{
|
||||
pos++;
|
||||
}
|
||||
int sidLen = pos - sidStart;
|
||||
strcopy(steamid, sidLen + 1, line[sidStart]);
|
||||
if (!StrEqual(steamid, sSID))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//if steam ID does not exist write all tiers
|
||||
write_all_tiers = false;
|
||||
write_newest_tier = true;
|
||||
|
||||
pos++; // skip closing quote of steamid
|
||||
while (line[pos] == ' ' || line[pos] == '\t') pos++; // skip whitespace
|
||||
pos++; // skip opening quote of group
|
||||
|
||||
int grpStart = pos;
|
||||
while (line[pos] != '"') pos++;
|
||||
int grpLen = pos - grpStart;
|
||||
strcopy(group, grpLen + 1, line[grpStart]);
|
||||
|
||||
// group is "@tier3", extract tier number
|
||||
char tierStr[8];
|
||||
strcopy(tierStr, sizeof(tierStr), group[5]); // skip "@tier"
|
||||
int tierNum = StringToInt(tierStr);
|
||||
if (tierNum == g_iPlayerTier[client])
|
||||
{
|
||||
write_newest_tier = false;
|
||||
break; //we confirmed the most recent tier was already written here.
|
||||
}
|
||||
}
|
||||
delete f;
|
||||
|
||||
if (write_all_tiers)
|
||||
{
|
||||
// Open file for appending
|
||||
File fAppend = OpenFile(sPath, "a");
|
||||
|
||||
for (int t = 1; t <= g_iPlayerTier[client]; t++)
|
||||
{
|
||||
char linewrite[256];
|
||||
Format(linewrite, sizeof(linewrite), "\"%s\" \"@tier%i\"\n", sSID, t);
|
||||
fAppend.WriteString(linewrite, false);
|
||||
}
|
||||
delete fAppend;
|
||||
SetTierRewards(client);
|
||||
|
||||
}
|
||||
else if (write_newest_tier)
|
||||
{
|
||||
// Open file for appending
|
||||
File fAppend = OpenFile(sPath, "a");
|
||||
char linewrite[256];
|
||||
Format(linewrite, sizeof(linewrite), "\"%s\" \"@tier%i\"\n", sSID, g_iPlayerTier[client]);
|
||||
fAppend.WriteString(linewrite, false);
|
||||
delete fAppend;
|
||||
SetTierRewards(client);
|
||||
}
|
||||
}
|
||||
@ -673,6 +799,8 @@ public void PrintClientGroupOverrides(int client)
|
||||
return;
|
||||
}
|
||||
|
||||
char rtv_boost_tier[32];
|
||||
Format(rtv_boost_tier, sizeof(rtv_boost_tier), "tier%i", g_iRtvBoost_tier);
|
||||
for (int i = 0; i < groupCount; i++)
|
||||
{
|
||||
char groupName[64];
|
||||
@ -682,10 +810,16 @@ public void PrintClientGroupOverrides(int client)
|
||||
continue;
|
||||
|
||||
char overrides[512];
|
||||
if (StrEqual(groupName, rtv_boost_tier))
|
||||
{
|
||||
PrintToChat(client, "tier%i access: %i mapvote/rtv/nomination boost", g_iRtvBoost_tier, g_iPlayerRTVCapacity);
|
||||
}
|
||||
if (g_GroupOverrides.GetString(groupName, overrides, sizeof(overrides)))
|
||||
PrintToChat(client, "access: %s", overrides);
|
||||
{
|
||||
PrintToChat(client, "%s access: %s", groupName, overrides);
|
||||
}
|
||||
}
|
||||
PrintToChat(client, "Extra playermodels in !zclass.");
|
||||
PrintToChat(client, "any tier access: playermodels in zclass.");
|
||||
}
|
||||
|
||||
public Action Command_Tier(int client, int args)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user