fixing handle and index errors, also added so mapgroup restrictions are respected
This commit is contained in:
parent
987c643838
commit
551588cb2b
@ -1022,6 +1022,7 @@ public Handle get_most_nominated_maps()
|
|||||||
sm.SetValue(map_iteration, nominate_count_for_particular_map, true);
|
sm.SetValue(map_iteration, nominate_count_for_particular_map, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static char map_[PLATFORM_MAX_PATH];
|
||||||
|
|
||||||
for (int i = 0; i < voteSize; i++)
|
for (int i = 0; i < voteSize; i++)
|
||||||
{
|
{
|
||||||
@ -1056,6 +1057,43 @@ public Handle get_most_nominated_maps()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
sm.Remove(picked_map);
|
sm.Remove(picked_map);
|
||||||
|
|
||||||
|
//2023 edit: respecting that only right amount of maps per group is allowed in vote
|
||||||
|
int groups_[32];
|
||||||
|
int groups[32];
|
||||||
|
int groupsfound = InternalGetMapGroups(picked_map, groups, sizeof(groups));
|
||||||
|
bool skip_nomination = false;
|
||||||
|
for (int group = 0; group < groupsfound; group ++)
|
||||||
|
{
|
||||||
|
int groupcur = 0;
|
||||||
|
int groupmax = InternalGetGroupMax(groups[group]);
|
||||||
|
if (groupmax >= 0)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < GetArraySize(most_nominated_maps); j++)
|
||||||
|
{
|
||||||
|
//Native_GetMapGroupRestriction
|
||||||
|
GetArrayString(most_nominated_maps, j, map_, PLATFORM_MAX_PATH);
|
||||||
|
int tmp = InternalGetMapGroups(map_, groups_, sizeof(groups_));
|
||||||
|
if (FindIntInArray(groups_, tmp, groups[group]) != -1)
|
||||||
|
{
|
||||||
|
groupcur++;
|
||||||
|
}
|
||||||
|
if (groupcur >= groupmax)
|
||||||
|
{
|
||||||
|
skip_nomination = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (skip_nomination)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (skip_nomination)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
PushArrayString(most_nominated_maps, picked_map);
|
PushArrayString(most_nominated_maps, picked_map);
|
||||||
//PrintToChatAll("picked_map: %s", picked_map);
|
//PrintToChatAll("picked_map: %s", picked_map);
|
||||||
}
|
}
|
||||||
@ -1807,7 +1845,7 @@ NominateResult InternalNominateMap(char[] map, int owner)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (owner != 0)
|
if (owner != 0 && g_NominateList[owner] != INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < GetArraySize(g_NominateList[owner]); j++)
|
for (int j = 0; j < GetArraySize(g_NominateList[owner]); j++)
|
||||||
{
|
{
|
||||||
@ -2360,9 +2398,10 @@ public int Native_GetMapGroups(Handle plugin, int numParams)
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//GetMapGroupRestriction
|
||||||
public int Native_GetMapGroupRestriction(Handle plugin, int numParams)
|
public int Native_GetMapGroupRestriction(Handle plugin, int numParams)
|
||||||
{
|
{
|
||||||
int client = GetNativeCell(2);
|
GetNativeCell(2);
|
||||||
int len;
|
int len;
|
||||||
GetNativeStringLength(1, len);
|
GetNativeStringLength(1, len);
|
||||||
|
|
||||||
@ -2401,28 +2440,6 @@ public int Native_GetMapGroupRestriction(Handle plugin, int numParams)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete kv;
|
delete kv;
|
||||||
|
|
||||||
if(groupcur >= groupmax)
|
|
||||||
{
|
|
||||||
// Check if client has nominated a map in the same group and can change their nomination
|
|
||||||
bool okay = false;
|
|
||||||
if(client >= 1 && client <= MaxClients)
|
|
||||||
{
|
|
||||||
int index = FindValueInArray(g_NominateOwners, client);
|
|
||||||
if(index != -1)
|
|
||||||
{
|
|
||||||
static char oldmap[PLATFORM_MAX_PATH];
|
|
||||||
GetArrayString(g_NominateList[client], index, oldmap, PLATFORM_MAX_PATH);
|
|
||||||
static int oldgroups[32];
|
|
||||||
int tmp = InternalGetMapGroups(oldmap, oldgroups, sizeof(oldgroups));
|
|
||||||
if(FindIntInArray(groups_, tmp, groups[group]) != -1)
|
|
||||||
okay = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!okay)
|
|
||||||
return groupmax;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,13 +324,6 @@ public Action Command_Addmap(int client, int args)
|
|||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GroupRestriction = GetMapGroupRestriction(mapname);
|
|
||||||
if(RestrictionsActive && GroupRestriction >= 0)
|
|
||||||
{
|
|
||||||
CPrintToChat(client, "[NE] %t", "Map Nominate Group Error", GroupRestriction);
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NominateResult result = NominateMap(mapname, true, 0);
|
NominateResult result = NominateMap(mapname, true, 0);
|
||||||
@ -603,13 +596,6 @@ public Action Command_Nominate(int client, int args)
|
|||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GroupRestriction = GetMapGroupRestriction(mapname, client);
|
|
||||||
if(RestrictionsActive && GroupRestriction >= 0)
|
|
||||||
{
|
|
||||||
CPrintToChat(client, "[NE] %t", "Map Nominate Group Error", GroupRestriction);
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
NominateResult result = NominateMap(mapname, false, client);
|
NominateResult result = NominateMap(mapname, false, client);
|
||||||
|
|
||||||
if (result == Nominate_InvalidMap)
|
if (result == Nominate_InvalidMap)
|
||||||
@ -903,7 +889,6 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
|||||||
GetMapCooldownTime(map) > GetTime() ||
|
GetMapCooldownTime(map) > GetTime() ||
|
||||||
GetMapTimeRestriction(map) ||
|
GetMapTimeRestriction(map) ||
|
||||||
GetMapPlayerRestriction(map) ||
|
GetMapPlayerRestriction(map) ||
|
||||||
GetMapGroupRestriction(map, param1) >= 0 ||
|
|
||||||
GetMapVIPRestriction(map, param1)))
|
GetMapVIPRestriction(map, param1)))
|
||||||
{
|
{
|
||||||
PrintToChat(param1, "[NE] You cant nominate this map right now.");
|
PrintToChat(param1, "[NE] You cant nominate this map right now.");
|
||||||
@ -972,7 +957,6 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
|||||||
GetMapCooldownTime(map) > GetTime() ||
|
GetMapCooldownTime(map) > GetTime() ||
|
||||||
GetMapTimeRestriction(map) ||
|
GetMapTimeRestriction(map) ||
|
||||||
GetMapPlayerRestriction(map) ||
|
GetMapPlayerRestriction(map) ||
|
||||||
GetMapGroupRestriction(map, param1) >= 0 ||
|
|
||||||
GetMapVIPRestriction(map, param1)))
|
GetMapVIPRestriction(map, param1)))
|
||||||
{
|
{
|
||||||
return ITEMDRAW_DISABLED;
|
return ITEMDRAW_DISABLED;
|
||||||
@ -1075,15 +1059,6 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
|||||||
return RedrawMenuItem(display);
|
return RedrawMenuItem(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
//2023 edit for multiple nominations
|
|
||||||
/*
|
|
||||||
int GroupRestriction = GetMapGroupRestriction(map, param1);
|
|
||||||
if(RestrictionsActive && GroupRestriction >= 0)
|
|
||||||
{
|
|
||||||
Format(display, sizeof(display), "%s (%T)", buffer, "Map Group Restriction", param1, GroupRestriction);
|
|
||||||
return RedrawMenuItem(display);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if(RestrictionsActive && VIPRestriction)
|
if(RestrictionsActive && VIPRestriction)
|
||||||
{
|
{
|
||||||
@ -1167,7 +1142,6 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
|
|||||||
GetMapCooldownTime(map) > GetTime() ||
|
GetMapCooldownTime(map) > GetTime() ||
|
||||||
GetMapTimeRestriction(map) ||
|
GetMapTimeRestriction(map) ||
|
||||||
GetMapPlayerRestriction(map) ||
|
GetMapPlayerRestriction(map) ||
|
||||||
GetMapGroupRestriction(map, param1) >= 0 ||
|
|
||||||
GetMapVIPRestriction(map, param1)))
|
GetMapVIPRestriction(map, param1)))
|
||||||
{
|
{
|
||||||
PrintToChat(param1, "[NE] You cant nominate this map right now.");
|
PrintToChat(param1, "[NE] You cant nominate this map right now.");
|
||||||
|
Loading…
Reference in New Issue
Block a user