added support for average hours count on server
This commit is contained in:
parent
d21303488b
commit
1c4f1d532c
2
mapchooser_extended/scripting/include/mapchooser_extended.inc
Normal file → Executable file
2
mapchooser_extended/scripting/include/mapchooser_extended.inc
Normal file → Executable file
@ -148,6 +148,8 @@ native bool AreRestrictionsActive();
|
||||
|
||||
native int SimulateMapEnd();
|
||||
|
||||
native int GetAveragePlayerTimeOnServerMapRestriction(const char[] map);
|
||||
|
||||
public SharedPlugin __pl_mapchooser_extended =
|
||||
{
|
||||
name = "mapchooser",
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <sourcemod>
|
||||
#include <mapchooser>
|
||||
#include <mapchooser_extended>
|
||||
#include <unloze_playtime>
|
||||
#include <nextmap>
|
||||
#include <sdktools>
|
||||
#include <multicolors>
|
||||
@ -304,6 +305,8 @@ public void OnPluginStart()
|
||||
|
||||
RegConsoleCmd("sm_extends", Command_ExtendsLeft, "sm_extends - Shows how many extends are left on the current map.");
|
||||
RegConsoleCmd("sm_extendsleft", Command_ExtendsLeft, "sm_extendsleft - Shows how many extends are left on the current map.");
|
||||
RegConsoleCmd("sm_houravg", Command_hours_average, "Prints in the chat what the current hour average of each player accumulated is.");
|
||||
RegConsoleCmd("sm_avghour", Command_hours_average, "Prints in the chat what the current hour average of each player accumulated is.");
|
||||
|
||||
g_Cvar_Winlimit = FindConVar("mp_winlimit");
|
||||
g_Cvar_Maxrounds = FindConVar("mp_maxrounds");
|
||||
@ -441,6 +444,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
||||
CreateNative("GetExtendsLeft", Native_GetExtendsLeft);
|
||||
CreateNative("AreRestrictionsActive", Native_AreRestrictionsActive);
|
||||
CreateNative("SimulateMapEnd", Native_SimulateMapEnd);
|
||||
CreateNative("GetAveragePlayerTimeOnServerMapRestriction", Native_GetAveragePlayerTimeOnServerMapRestriction);
|
||||
|
||||
return APLRes_Success;
|
||||
}
|
||||
@ -665,6 +669,12 @@ public Action Command_ReloadMaps(int client, int args)
|
||||
InitializeOfficialMapList();
|
||||
}
|
||||
|
||||
public Action Command_hours_average(int client, int args)
|
||||
{
|
||||
PrintToChat(client, "Average hour count is: %i", GetAveragePlayerTimeOnServer());
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action Command_ExtendsLeft(int client, int args)
|
||||
{
|
||||
CReplyToCommand(client, "[MCE] Available Extends: %d", GetConVarInt(g_Cvar_Extend) - g_Extends);
|
||||
@ -2367,6 +2377,33 @@ public int Native_GetMapTimeRestriction(Handle plugin, int numParams)
|
||||
return InternalGetMapTimeRestriction(map);
|
||||
}
|
||||
|
||||
//GetAveragePlayerTimeOnServerMapRestriction
|
||||
public int Native_GetAveragePlayerTimeOnServerMapRestriction(Handle plugin, int numParams)
|
||||
{
|
||||
int len;
|
||||
GetNativeStringLength(1, len);
|
||||
|
||||
if(len <= 0)
|
||||
return false;
|
||||
|
||||
char[] map = new char[len+1];
|
||||
GetNativeString(1, map, len+1);
|
||||
int players_average_hours = GetAveragePlayerTimeOnServer();
|
||||
int MinAverageHours = 0;
|
||||
if(g_Config && g_Config.JumpToKey(map))
|
||||
{
|
||||
MinAverageHours = g_Config.GetNum("MinHoursAvg", MinAverageHours);
|
||||
g_Config.Rewind();
|
||||
}
|
||||
//0 means map can be nominated, anything above 0 means more hours are required
|
||||
if (players_average_hours >= MinAverageHours)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return MinAverageHours - players_average_hours;
|
||||
}
|
||||
|
||||
//GetMapPlayerRestriction
|
||||
public int Native_GetMapPlayerRestriction(Handle plugin, int numParams)
|
||||
{
|
||||
int len;
|
||||
|
@ -424,6 +424,13 @@ public Action Command_Addmap(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
int AverageHourRestricted = GetAveragePlayerTimeOnServerMapRestriction(mapname);
|
||||
if (AverageHourRestricted > 0)
|
||||
{
|
||||
PrintToChat(client, "%s requires +%i hours average. Use sm_houravg to check average.", mapname, AverageHourRestricted);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
int PlayerRestriction = GetMapPlayerRestriction(mapname);
|
||||
if(RestrictionsActive && PlayerRestriction)
|
||||
{
|
||||
@ -695,6 +702,13 @@ public Action Command_Nominate(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
int AverageHourRestricted = GetAveragePlayerTimeOnServerMapRestriction(mapname);
|
||||
if (AverageHourRestricted > 0)
|
||||
{
|
||||
PrintToChat(client, "%s requires +%i hours average. Use sm_houravg to check average.", mapname, AverageHourRestricted);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
int PlayerRestriction = GetMapPlayerRestriction(mapname);
|
||||
if(RestrictionsActive && PlayerRestriction)
|
||||
{
|
||||
@ -1003,6 +1017,7 @@ Menu BuildMapMenu(const char[] filter, int client)
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetAveragePlayerTimeOnServerMapRestriction(map) > 0 ||
|
||||
GetMapVIPRestriction(map, client)))
|
||||
{
|
||||
continue;
|
||||
@ -1098,6 +1113,7 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetAveragePlayerTimeOnServerMapRestriction(map) > 0 ||
|
||||
GetMapVIPRestriction(map, param1)))
|
||||
{
|
||||
PrintToChat(param1, "[NE] You cant nominate this map right now.");
|
||||
@ -1167,6 +1183,7 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetAveragePlayerTimeOnServerMapRestriction(map) > 0 ||
|
||||
GetMapVIPRestriction(map, param1)))
|
||||
{
|
||||
return ITEMDRAW_DISABLED;
|
||||
@ -1258,6 +1275,13 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
return RedrawMenuItem(display);
|
||||
}
|
||||
|
||||
int AverageHourRestricted = GetAveragePlayerTimeOnServerMapRestriction(map);
|
||||
if (AverageHourRestricted > 0)
|
||||
{
|
||||
Format(display, sizeof(display), "%s requires +%i hours average.", map, AverageHourRestricted);
|
||||
return RedrawMenuItem(display);
|
||||
}
|
||||
|
||||
int PlayerRestriction = GetMapPlayerRestriction(map);
|
||||
if(RestrictionsActive && PlayerRestriction)
|
||||
{
|
||||
@ -1352,6 +1376,7 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetAveragePlayerTimeOnServerMapRestriction(map) > 0 ||
|
||||
GetMapVIPRestriction(map, param1)))
|
||||
{
|
||||
PrintToChat(param1, "[NE] You cant nominate this map right now.");
|
||||
|
Loading…
Reference in New Issue
Block a user