diff --git a/Leader2/scripting/Leader2.sp b/Leader2/scripting/Leader2.sp index 956b9a5b..f59d6dd1 100644 --- a/Leader2/scripting/Leader2.sp +++ b/Leader2/scripting/Leader2.sp @@ -1439,6 +1439,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max { CreateNative("Leader_CurrentLeader", Native_CurrentLeader); CreateNative("Leader_SetLeader", Native_SetLeader); + CreateNative("Leader_Is", Native_IsPossibleLeader); return APLRes_Success; } @@ -1457,6 +1458,13 @@ public int Native_SetLeader(Handle plugin, int numParams) { SetLeader(GetNativeCell(1)); } +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public int Native_IsPossibleLeader(Handle plugin, int numParams) +{ + return IsPossibleLeader(GetNativeCell(1)); +} //---------------------------------------------------------------------------------------------------- // Purpose: @@ -1595,4 +1603,4 @@ bool TracePlayerAngles(int client, float vecResult[3]) stock bool TraceEntityFilter_FilterPlayers(int entity, int contentsMask) { return entity > MaxClients; -} \ No newline at end of file +} diff --git a/Leader2/scripting/include/leader.inc b/Leader2/scripting/include/leader.inc index 987ee5b1..96597327 100644 --- a/Leader2/scripting/include/leader.inc +++ b/Leader2/scripting/include/leader.inc @@ -15,3 +15,9 @@ native Leader_CurrentLeader(); * @param client Client index to be set as leader */ native Leader_SetLeader(client); +/** + * checks if client is possible leader + * + * @param client Client index to check if leader + */ +native Leader_Is(client); diff --git a/mapchooser_extended/scripting/mapchooser_extended_avg.sp b/mapchooser_extended/scripting/mapchooser_extended_avg.sp index 19c36e9d..79c39d13 100755 --- a/mapchooser_extended/scripting/mapchooser_extended_avg.sp +++ b/mapchooser_extended/scripting/mapchooser_extended_avg.sp @@ -55,6 +55,7 @@ #include #include #include +#include #pragma semicolon 1 #pragma newdecls required @@ -1059,11 +1060,6 @@ public Handle get_most_nominated_maps(bool create_next_vote) Handle most_nominated_maps = CreateArray(arraySize); StringMap sm = new StringMap(); - //november 2023 edit: now the leader can nominate one map per map played that can skip requirements: Expectation is the leader will want to lead the map. - //if leaders abuse the feature they should simply be removed from the leader list file. - char MapleaderNominatedMap[PLATFORM_MAX_PATH]; - GetMapleaderNominatedMap(MapleaderNominatedMap); - for (int i = 0; i < MaxClients; i++) { for (int j = 0; j < GetArraySize(g_NominateList[i]); j++) @@ -1079,7 +1075,7 @@ public Handle get_most_nominated_maps(bool create_next_vote) { nominate_count_for_particular_map = 1999; } - else if(StrEqual(map_iteration, MapleaderNominatedMap, false)) + else if(Leader_Is(i)) { nominate_count_for_particular_map = 999; } @@ -2024,6 +2020,9 @@ void CreateNextVote() if(InternalGetMapVIPRestriction(map)) continue; + if(InternalGetMapCooldownTime(map) > GetTime()) + continue; + if(InternalGetMapTimeRestriction(map) != 0) continue; diff --git a/mapchooser_extended/scripting/nominations_extended_avg.sp b/mapchooser_extended/scripting/nominations_extended_avg.sp index a4ffa638..c0100023 100755 --- a/mapchooser_extended/scripting/nominations_extended_avg.sp +++ b/mapchooser_extended/scripting/nominations_extended_avg.sp @@ -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))