forked from UNLOZE/sm-plugins
added native to leader to get if a client if one of the possible leaders. added to mapchooser that random picked maps respect cooldowns as well. changed so leaders and admins skip all cooldowns and restrictions
This commit is contained in:
@@ -84,8 +84,6 @@ Handle g_Cvar_VIPTimeframeMaxTime = INVALID_HANDLE;
|
||||
|
||||
int g_Player_NominationDelay[MAXPLAYERS+1];
|
||||
int g_NominationDelay;
|
||||
int g_iMapleaderWhoNominatedMap = -1;
|
||||
char g_cMapLeaderNominatedMap[256];
|
||||
|
||||
//clients ignoring maps that are unavailable
|
||||
bool g_bClientsIgnoring[MAXPLAYERS + 1];
|
||||
@@ -139,8 +137,6 @@ public void OnPluginStart()
|
||||
|
||||
public void OnMapStart()
|
||||
{
|
||||
Format(g_cMapLeaderNominatedMap, sizeof(g_cMapLeaderNominatedMap), "");
|
||||
g_iMapleaderWhoNominatedMap = -1;
|
||||
if (!g_dDatabase)
|
||||
{
|
||||
//we have too many dbs so i am just re-using racetimercss
|
||||
@@ -265,7 +261,6 @@ public APLRes AskPluginLoad2(Handle hThis, bool bLate, char[] err, int iErrLen)
|
||||
CreateNative("PushMapsIntoNominationPool", Native_PushMapsIntoNominationPool);
|
||||
CreateNative("RemoveMapFromNominationPool", Native_RemoveMapFromNominationPool);
|
||||
CreateNative("RemoveMapsFromNominationPool", Native_RemoveMapsFromNominationPool);
|
||||
CreateNative("GetMapleaderNominatedMap", Native_GetMapleaderNominatedMap);
|
||||
|
||||
return APLRes_Success;
|
||||
}
|
||||
@@ -375,29 +370,6 @@ public void OnNominationRemoved(const char[] map, int client)
|
||||
/* Is the map in our list? */
|
||||
if(!GetTrieValue(g_mapTrie, map, status))
|
||||
return;
|
||||
int newclient = 0;
|
||||
//just differientiating between if nomination was removed because of starting vote or because of anything else possible.
|
||||
if (client > 100)
|
||||
{
|
||||
newclient = client - 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
newclient = client;
|
||||
}
|
||||
if (newclient == g_iMapleaderWhoNominatedMap && StrEqual(map, g_cMapLeaderNominatedMap, false))
|
||||
{
|
||||
if (client > 100)
|
||||
{
|
||||
CPrintToChatAll("{darkorange}[UNLOZE Nominations] {white}The map leader {lightgreen}%N {white}nomination {red}%s {white}was forced into the mapvote.", newclient, map);
|
||||
}
|
||||
else
|
||||
{
|
||||
CPrintToChatAll("{darkorange}[UNLOZE Nominations] {white}The map leader {lightgreen}%N {white}has removed his Mapleader nomination {red}%s", newclient, map);
|
||||
}
|
||||
Format(g_cMapLeaderNominatedMap, sizeof(g_cMapLeaderNominatedMap), "");
|
||||
g_iMapleaderWhoNominatedMap = -1;
|
||||
}
|
||||
/* Was the map disabled due to being nominated */
|
||||
if((status & MAPSTATUS_EXCLUDE_NOMINATED) != MAPSTATUS_EXCLUDE_NOMINATED)
|
||||
return;
|
||||
@@ -706,37 +678,29 @@ public Action Command_Nominate(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
bool RestrictionsActive = AreRestrictionsActive();
|
||||
|
||||
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
|
||||
//July 2024 edit: any person who is potential leader can just skip all cooldowns and map restrictions. same for admins.
|
||||
if(!CheckCommandAccess(client, "sm_nominate_ignore", ADMFLAG_KICK, true) && !Leader_Is(client))
|
||||
{
|
||||
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
|
||||
ReplyToCommand(client, "Cant Nominate Current Map.");
|
||||
//CPrintToChat(client, "[NE] %t", "Cant Nominate Current Map");
|
||||
bool RestrictionsActive = AreRestrictionsActive();
|
||||
|
||||
if(RestrictionsActive && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
|
||||
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
|
||||
{
|
||||
int Cooldown = GetMapCooldown(mapname);
|
||||
CPrintToChat(client, "[NE] %t (%d)", "Map in Exclude List", Cooldown);
|
||||
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
|
||||
ReplyToCommand(client, "Cant Nominate Current Map.");
|
||||
//CPrintToChat(client, "[NE] %t", "Cant Nominate Current Map");
|
||||
|
||||
if(RestrictionsActive && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
|
||||
{
|
||||
int Cooldown = GetMapCooldown(mapname);
|
||||
CPrintToChat(client, "[NE] %t (%d)", "Map in Exclude List", Cooldown);
|
||||
}
|
||||
|
||||
if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
|
||||
CPrintToChat(client, "[NE] %t", "Map Already Nominated");
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
|
||||
CPrintToChat(client, "[NE] %t", "Map Already Nominated");
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
int mapLeader = Leader_CurrentLeader();
|
||||
//2023 November edit: one map nominated by mapleader will automatically go to the vote.
|
||||
if (client == mapLeader && StrEqual(g_cMapLeaderNominatedMap, ""))
|
||||
{
|
||||
CPrintToChatAll("{darkorange}[UNLOZE Nominations] {white}The map leader {lightgreen}%N {white}has nominated the map {red}%s{white}. The map will be in the next mapvote.", client, mapname);
|
||||
CPrintToChatAll("{lightblue}If the map is nextmap and the leader wont play it he will be removed from leader access.");
|
||||
Format(g_cMapLeaderNominatedMap, sizeof(g_cMapLeaderNominatedMap), mapname);
|
||||
g_iMapleaderWhoNominatedMap = client;
|
||||
}
|
||||
else
|
||||
{
|
||||
int Cooldown = GetMapCooldownTime(mapname);
|
||||
if(RestrictionsActive && Cooldown > GetTime())
|
||||
{
|
||||
@@ -884,21 +848,13 @@ void AttemptNominate(int client, const char[] filter = "")
|
||||
Menu menu = g_MapMenu;
|
||||
menu = BuildMapMenu(filter, client);
|
||||
|
||||
int mapLeader = Leader_CurrentLeader();
|
||||
if (client == mapLeader && StrEqual(g_cMapLeaderNominatedMap, ""))
|
||||
GetPlayerWorthRTV_(client);
|
||||
int nominate_worth = RoundToFloor(GetPlayerWorthRTV_boost_(client));
|
||||
if (nominate_worth < 1)
|
||||
{
|
||||
SetMenuTitle(menu, "Nominate Map as Mapleader:", client);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetPlayerWorthRTV_(client);
|
||||
int nominate_worth = RoundToFloor(GetPlayerWorthRTV_boost_(client));
|
||||
if (nominate_worth < 1)
|
||||
{
|
||||
nominate_worth = 1;
|
||||
}
|
||||
SetMenuTitle(menu, "%T", "Nominate Title", client, nominate_worth);
|
||||
nominate_worth = 1;
|
||||
}
|
||||
SetMenuTitle(menu, "%T", "Nominate Title", client, nominate_worth);
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
@@ -981,12 +937,12 @@ bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "")
|
||||
int owner = GetArrayCell(OwnerList, i);
|
||||
int nominate_count_for_particular_map = 0;
|
||||
sm.GetValue(map, nominate_count_for_particular_map);
|
||||
//if its console its admin nomination. if its g_iMapleaderWhoNominatedMap it was map nominated by leader, also has to be correct map out of 3.
|
||||
//if its console its admin nomination. if its nominated by leader it will also go to the vote just.
|
||||
if (!owner)
|
||||
{
|
||||
nominate_count_for_particular_map = 1999;
|
||||
}
|
||||
else if(owner == g_iMapleaderWhoNominatedMap && StrEqual(map, g_cMapLeaderNominatedMap))
|
||||
else if(Leader_Is(owner))
|
||||
{
|
||||
nominate_count_for_particular_map = 999;
|
||||
}
|
||||
@@ -1035,11 +991,9 @@ bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "")
|
||||
|
||||
if(!owner)
|
||||
Format(display, sizeof(display), "%s (Admin)", display);
|
||||
else if (StrEqual(map, g_cMapLeaderNominatedMap))
|
||||
else if (Leader_Is(owner))
|
||||
{
|
||||
char leadername[MAX_NAME_LENGTH];
|
||||
GetClientName(g_iMapleaderWhoNominatedMap, leadername, MAX_NAME_LENGTH);
|
||||
Format(display, sizeof(display), "%s (Mapleader %s)", display, leadername);
|
||||
Format(display, sizeof(display), "%s (Mapleader)", display);
|
||||
}
|
||||
else
|
||||
Format(display, sizeof(display), "%s (%i %s)", display, nominate_count_for_particular_map, spelling);
|
||||
@@ -1213,24 +1167,18 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
|
||||
GetClientName(param1, name, MAX_NAME_LENGTH);
|
||||
|
||||
int mapLeader = Leader_CurrentLeader();
|
||||
//2023 November edit: one map nominated by mapleader will automatically go to the vote.
|
||||
if (param1 == mapLeader && StrEqual(g_cMapLeaderNominatedMap, ""))
|
||||
if(!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_KICK, true) && !Leader_Is(param1))
|
||||
{
|
||||
CPrintToChatAll("{darkorange}[UNLOZE Nominations] {white}The map leader {lightgreen}%N {white}has nominated the map {red}%s{white}. The map will be in the mapvote.", param1, map);
|
||||
CPrintToChatAll("{lightblue}If the map is nextmap and the leader wont play it he will be removed from leader access.");
|
||||
Format(g_cMapLeaderNominatedMap, sizeof(g_cMapLeaderNominatedMap), map);
|
||||
g_iMapleaderWhoNominatedMap = param1;
|
||||
}
|
||||
else if(AreRestrictionsActive() && (
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetAveragePlayerTimeOnServerMapRestriction(map) > 0 ||
|
||||
GetMapVIPRestriction(map, param1)))
|
||||
{
|
||||
PrintToChat(param1, "[NE] You cant nominate this map right now.");
|
||||
return 0;
|
||||
if(AreRestrictionsActive() && (
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetAveragePlayerTimeOnServerMapRestriction(map) > 0 ||
|
||||
GetMapVIPRestriction(map, param1)))
|
||||
{
|
||||
PrintToChat(param1, "[NE] You cant nominate this map right now.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
NominateResult result = NominateMap(map, false, param1);
|
||||
@@ -1301,22 +1249,18 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
}
|
||||
}
|
||||
|
||||
int mapLeader = Leader_CurrentLeader();
|
||||
if (param1 == mapLeader && StrEqual(g_cMapLeaderNominatedMap, ""))
|
||||
if(!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_KICK, true) && !Leader_Is(param1))
|
||||
{
|
||||
return ITEMDRAW_DEFAULT;
|
||||
if(AreRestrictionsActive() && (
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetAveragePlayerTimeOnServerMapRestriction(map) > 0 ||
|
||||
GetMapVIPRestriction(map, param1)))
|
||||
{
|
||||
return ITEMDRAW_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
if(AreRestrictionsActive() && (
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetAveragePlayerTimeOnServerMapRestriction(map) > 0 ||
|
||||
GetMapVIPRestriction(map, param1)))
|
||||
{
|
||||
return ITEMDRAW_DISABLED;
|
||||
}
|
||||
|
||||
return ITEMDRAW_DEFAULT;
|
||||
}
|
||||
|
||||
@@ -1663,12 +1607,6 @@ public int Native_RemoveMapsFromNominationPool(Handle plugin, int numArgs)
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int Native_GetMapleaderNominatedMap(Handle plugin, int numArgs)
|
||||
{
|
||||
SetNativeString(1, g_cMapLeaderNominatedMap, sizeof(g_cMapLeaderNominatedMap), true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
stock int GetVIPTimeRestriction()
|
||||
{
|
||||
if (!GetConVarBool(g_Cvar_VIPTimeframe))
|
||||
|
||||
Reference in New Issue
Block a user