Skip to content

Commit 78c5a81

Browse files
committed
Show player-limit exclusion in nomination menus
Add player count checks and exclusion gestures to nomination menus. Defines two new gestures for min/max player limits in include/multimode/utils.inc and updates gamemode, subgroup and map nomination menus to: retrieve current player count, determine min/max constraints (map-specific → subgroup → gamemode fallbacks), format an explanatory gesture ("Minimum X Players" / "Max X Players") and show the item as disabled with that gesture when the player count violates limits. This provides clearer feedback to users why a nomination is unavailable.
1 parent ad142e4 commit 78c5a81

2 files changed

Lines changed: 103 additions & 0 deletions

File tree

addons/sourcemod/scripting/include/multimode/utils.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#define GESTURE_VOTED " (#)" // For Winning group/map global gesture from a previous vote
1919
#define GESTURE_SELECTEDNOMINATED " (Nominated)" // For selected nomination global gesture.
2020
#define GESTURE_EXCLUDED " (Excluded)" // For global exclusion gesture.
21+
#define GESTURE_EXCLUDED_PLAYERLIMIT_MINIMUM " (Minimum %d Players)" // For global player limit minimum exclusion gesture.
22+
#define GESTURE_EXCLUDED_PLAYERLIMIT_MAX " (Max %d Players)" // For global player limit maximum exclusion gesture.
2123

2224
/**
2325
* Fills buffer with the current map cycle filename (from multimode_mapcycle convar).

addons/sourcemod/scripting/multimode_nominations.sp

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,35 @@ void ShowNominateGamemodeMenu(int client)
328328

329329
bool isRecentlyPlayed = (groupExclude > 0 && MultiMode_IsGamemodeRecentlyPlayed(gamemode, groupExclude));
330330
bool canNominate = MMC_CanClientNominate(client, gamemode);
331+
332+
int players = GetRealClientCount();
333+
bool exceedsPlayerLimit = false;
334+
char playerLimitGesture[32];
335+
int gIndex = MMC_FindGameModeIndex(gamemode);
336+
if (gIndex != -1) {
337+
GameModeConfig gmCfg;
338+
GetGameModesList().GetArray(gIndex, gmCfg);
339+
if (gmCfg.minplayers > 0 && players < gmCfg.minplayers) {
340+
exceedsPlayerLimit = true;
341+
Format(playerLimitGesture, sizeof(playerLimitGesture), GESTURE_EXCLUDED_PLAYERLIMIT_MINIMUM, gmCfg.minplayers);
342+
} else if (gmCfg.maxplayers > 0 && players > gmCfg.maxplayers) {
343+
exceedsPlayerLimit = true;
344+
Format(playerLimitGesture, sizeof(playerLimitGesture), GESTURE_EXCLUDED_PLAYERLIMIT_MAX, gmCfg.maxplayers);
345+
}
346+
}
347+
331348
char display[128];
332349

333350
if (!canNominate)
334351
{
335352
Format(display, sizeof(display), "%s%s", gamemode, GESTURE_EXCLUDED);
336353
menu.AddItem(gamemode, display, ITEMDRAW_DISABLED);
337354
}
355+
else if (exceedsPlayerLimit)
356+
{
357+
Format(display, sizeof(display), "%s%s", gamemode, playerLimitGesture);
358+
menu.AddItem(gamemode, display, ITEMDRAW_DISABLED);
359+
}
338360
else if (g_Cvar_Nominate_NominateSelectedGroupExclude.BoolValue && isNominated)
339361
{
340362
Format(display, sizeof(display), "%s%s", gamemode, GESTURE_SELECTEDNOMINATED);
@@ -424,13 +446,38 @@ void ShowNominateSubGroupMenu(int client, const char[] gamemode)
424446
bool isNominated = MultiMode_IsGroupNominated(gamemode, subgroup);
425447
bool isRecentlyPlayed = (subgroupExclude > 0 && MultiMode_IsSubGroupRecentlyPlayed(gamemode, subgroup, subgroupExclude));
426448
bool canNominate = MMC_CanClientNominate(client, gamemode, subgroup);
449+
450+
int players = GetRealClientCount();
451+
bool exceedsPlayerLimit = false;
452+
char playerLimitGesture[32];
453+
int gIdx = MMC_FindGameModeIndex(gamemode);
454+
int sIdx = MMC_FindSubGroupIndex(gamemode, subgroup);
455+
if (gIdx != -1 && sIdx != -1) {
456+
GameModeConfig gmCfg;
457+
GetGameModesList().GetArray(gIdx, gmCfg);
458+
SubGroupConfig subCfg;
459+
gmCfg.subGroups.GetArray(sIdx, subCfg);
460+
if (subCfg.minplayers > 0 && players < subCfg.minplayers) {
461+
exceedsPlayerLimit = true;
462+
Format(playerLimitGesture, sizeof(playerLimitGesture), GESTURE_EXCLUDED_PLAYERLIMIT_MINIMUM, subCfg.minplayers);
463+
} else if (subCfg.maxplayers > 0 && players > subCfg.maxplayers) {
464+
exceedsPlayerLimit = true;
465+
Format(playerLimitGesture, sizeof(playerLimitGesture), GESTURE_EXCLUDED_PLAYERLIMIT_MAX, subCfg.maxplayers);
466+
}
467+
}
468+
427469
char display[128];
428470

429471
if (!canNominate)
430472
{
431473
Format(display, sizeof(display), "%s%s", subgroup, GESTURE_EXCLUDED);
432474
menu.AddItem(subgroup, display, ITEMDRAW_DISABLED);
433475
}
476+
else if (exceedsPlayerLimit)
477+
{
478+
Format(display, sizeof(display), "%s%s", subgroup, playerLimitGesture);
479+
menu.AddItem(subgroup, display, ITEMDRAW_DISABLED);
480+
}
434481
else if (g_Cvar_Nominate_NominateSelectedGroupExclude.BoolValue && isNominated)
435482
{
436483
Format(display, sizeof(display), "%s%s", subgroup, GESTURE_SELECTEDNOMINATED);
@@ -531,6 +578,55 @@ void ShowNominateMapMenu(int client, const char[] gamemode, const char[] subgrou
531578
bool isNominated = MultiMode_IsMapNominated(gamemode, subgroup, map);
532579
bool isRecentlyPlayed = (mapExclude > 0 && MultiMode_IsMapRecentlyPlayed(gamemode, map, subgroup, mapExclude));
533580
bool canNominate = MMC_CanClientNominate(client, gamemode, subgroup, map) && !MMC_IsMapAdminOnly(gamemode, map, subgroup);
581+
582+
int players = GetRealClientCount();
583+
bool exceedsPlayerLimit = false;
584+
char playerLimitGesture[32];
585+
int minP = 0, maxP = 0;
586+
587+
KeyValues mapKv = null;
588+
if (strlen(subgroup) > 0)
589+
mapKv = MMC_GetSubGroupMapKv(g_kvGameModes, gamemode, subgroup, map);
590+
else
591+
mapKv = MMC_GetMapKv(g_kvGameModes, gamemode, map);
592+
593+
if (mapKv != null) {
594+
minP = mapKv.GetNum(MAPCYCLE_KEY_MINPLAYERS, 0);
595+
maxP = mapKv.GetNum(MAPCYCLE_KEY_MAXPLAYERS, 0);
596+
delete mapKv;
597+
}
598+
599+
if (minP == 0 && maxP == 0 && strlen(subgroup) > 0) {
600+
int sgIdx = MMC_FindSubGroupIndex(gamemode, subgroup);
601+
int gIdx = MMC_FindGameModeIndex(gamemode);
602+
if (gIdx != -1 && sgIdx != -1) {
603+
GameModeConfig gmCfg;
604+
GetGameModesList().GetArray(gIdx, gmCfg);
605+
SubGroupConfig subCfg;
606+
gmCfg.subGroups.GetArray(sgIdx, subCfg);
607+
minP = subCfg.minplayers;
608+
maxP = subCfg.maxplayers;
609+
}
610+
}
611+
612+
if (minP == 0 && maxP == 0) {
613+
int gIdx = MMC_FindGameModeIndex(gamemode);
614+
if (gIdx != -1) {
615+
GameModeConfig gmCfg;
616+
GetGameModesList().GetArray(gIdx, gmCfg);
617+
if (minP == 0) minP = gmCfg.minplayers;
618+
if (maxP == 0) maxP = gmCfg.maxplayers;
619+
}
620+
}
621+
622+
if (minP > 0 && players < minP) {
623+
exceedsPlayerLimit = true;
624+
Format(playerLimitGesture, sizeof(playerLimitGesture), GESTURE_EXCLUDED_PLAYERLIMIT_MINIMUM, minP);
625+
} else if (maxP > 0 && players > maxP) {
626+
exceedsPlayerLimit = true;
627+
Format(playerLimitGesture, sizeof(playerLimitGesture), GESTURE_EXCLUDED_PLAYERLIMIT_MAX, maxP);
628+
}
629+
534630
char displayName[256];
535631
MultiMode_GetMapDisplayName(gamemode, map, subgroup, displayName, sizeof(displayName));
536632

@@ -539,6 +635,11 @@ void ShowNominateMapMenu(int client, const char[] gamemode, const char[] subgrou
539635
Format(displayName, sizeof(displayName), "%s%s", displayName, GESTURE_EXCLUDED);
540636
menu.AddItem(map, displayName, ITEMDRAW_DISABLED);
541637
}
638+
else if (exceedsPlayerLimit)
639+
{
640+
Format(displayName, sizeof(displayName), "%s%s", displayName, playerLimitGesture);
641+
menu.AddItem(map, displayName, ITEMDRAW_DISABLED);
642+
}
542643
else if (g_Cvar_Nominate_NominateSelectedMapExclude.BoolValue && isNominated)
543644
{
544645
Format(displayName, sizeof(displayName), "%s%s", displayName, GESTURE_SELECTEDNOMINATED);

0 commit comments

Comments
 (0)