mapvote 2.1.0

Made it possible to have a default randomized map and mode from a user defined list when the human players count is between two values defined by the user

Added dvar mapvote_default_rotation_maps
Added dvar mapvote_default_rotation_modes (MP only)
Added dvar mapvote_default_rotation_min_players
Added dvar mapvote_default_rotation_max_players
This commit is contained in:
Resxt 2023-01-21 03:53:50 +01:00
parent f087a83c6b
commit 70b5caf159
7 changed files with 68 additions and 10 deletions

View File

@ -77,6 +77,10 @@ Here are the dvars you can configure:
| mapvote_blur_fade_in_time | The time (in seconds) it takes for the blur to reach `mapvote_blur_level`. For example if you set it to 10 and `mapvote_blur_level` is 5 then it will progressively blur the screen from 0 to 5 in 10 seconds | 2 | Any number |
| mapvote_horizontal_spacing | The horizontal spacing between the map/mode names on the left and the vote counts on the right. I recommend setting this value according to the longest map or mode name length so that it doesn't overlap with the vote counts | 75 | Any plain number |
| mapvote_display_wait_time | Once the killcam ends, the time to wait before displaying the vote menu (in seconds) | 1 | Any number superior or equal to 0.05 |
| mapvote_default_rotation_maps | A list of the maps that are available for default rotation | "Hijacked:Raid:Nuketown" | Any map name. Each map is separated with a colon (:) |
| mapvote_default_rotation_modes | A list of the modes that are available for default rotation. It needs to be the name of a CFG file | "tdm" | Any cfg file name. Each cfg file name is separated with a colon (:) |
| mapvote_default_rotation_min_players | The minimum amount of human players required to rotate the default rotation instead of showing the mapvote. If the human players count is smaller than this then it will display the mapvote | 0 | Any plain number from 0 to 18 |
| mapvote_default_rotation_max_players | The maximum amount of human players required to rotate the default rotation instead of showing the mapvote. If the human players count is higher than this then it will display the mapvote | 0 | Any plain number from 0 to 18 |
</details>
@ -101,6 +105,9 @@ Here are the dvars you can configure:
| mapvote_blur_fade_in_time | The time (in seconds) it takes for the blur to reach `mapvote_blur_level`. For example if you set it to 10 and `mapvote_blur_level` is 5 then it will progressively blur the screen from 0 to 5 in 10 seconds | 2 | Any number |
| mapvote_horizontal_spacing | The horizontal spacing between the map names on the left and the vote counts on the right. I recommend setting this value according to the longest map name length so that it doesn't overlap with the vote counts | 75 | Any plain number |
| mapvote_display_wait_time | Once the game over screen ends, the time to wait before displaying the vote menu (in seconds) | 1 | Any number above 0.05 |
| mapvote_default_rotation_maps | A list of the maps that are available for default rotation | "Town,zm_standard_town:Farm,zm_standard_farm" | The map name followed by a comma (,) and then the CFG file name. Each block is separated with a colon (:) |
| mapvote_default_rotation_min_players | The minimum amount of human players required to rotate the default rotation instead of showing the mapvote. If the human players count is smaller than this then it will display the mapvote | 0 | Any plain number from 0 to 18 |
| mapvote_default_rotation_max_players | The maximum amount of human players required to rotate the default rotation instead of showing the mapvote. If the human players count is higher than this then it will display the mapvote | 0 | Any plain number from 0 to 18 |
</details>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -20,8 +20,7 @@ Init()
{
if (GetDvarInt("mapvote_enable"))
{
level.mapvote_start_function = ::StartVote;
level.mapvote_end_function = ::ListenForEndVote;
level.mapvote_rotate_function = ::DoRotation;
InitMapvote();
}
@ -61,10 +60,13 @@ InitDvars()
SetDvarIfNotInitialized("mapvote_limits_modes", 0);
SetDvarIfNotInitialized("mapvote_sounds_menu_enabled", 1);
SetDvarIfNotInitialized("mapvote_sounds_timer_enabled", 1);
SetDvarIfNotInitialized("mapvote_default_rotation_maps", "Hijacked:Raid:Nuketown");
SetDvarIfNotInitialized("mapvote_default_rotation_modes", "tdm");
}
else
{
SetDvarIfNotInitialized("mapvote_maps", "Bus Depot,Bus Depot,zm_standard_transit:Town,Town,zm_standard_town:Farm,Farm,zm_standard_farm:Mob of The Dead,Mob of The Dead,zm_classic_prison:Nuketown,Nuketown,zm_standard_nuked:Origins,Origins,zm_classic_tomb:Buried,Buried,zm_classic_processing:Die Rise,Die Rise,zm_classic_rooftop");
SetDvarIfNotInitialized("mapvote_default_rotation_maps", "Town,zm_standard_town:Farm,zm_standard_farm");
}
SetDvarIfNotInitialized("mapvote_limits_max", 12);
@ -80,6 +82,8 @@ InitDvars()
SetDvarIfNotInitialized("mapvote_blur_fade_in_time", 2);
SetDvarIfNotInitialized("mapvote_horizontal_spacing", 75);
SetDvarIfNotInitialized("mapvote_display_wait_time", 1);
SetDvarIfNotInitialized("mapvote_default_rotation_min_players", 0);
SetDvarIfNotInitialized("mapvote_default_rotation_max_players", 0);
}
InitVariables()
@ -662,6 +666,54 @@ GetVoteLimits(mapsAmount, modesAmount)
return limits;
}
ShouldRotateDefault()
{
humanPlayersCount = GetHumanPlayers().size;
if (GetDvarInt("mapvote_default_rotation_max_players") > 0 && humanPlayersCount >= GetDvarInt("mapvote_default_rotation_min_players") && humanPlayersCount <= GetDvarInt("mapvote_default_rotation_max_players"))
{
return true;
}
return false;
}
RotateDefault()
{
mapName = "";
modeCfg = "";
if (IsMultiplayerMode())
{
modeCfg = GetRandomElementInArray(StrTok(GetDvar("mapvote_default_rotation_modes"), ":"));
mapName = GetMapCodeName(GetRandomElementInArray(StrTok(GetDvar("mapvote_default_rotation_maps"), ":")));
}
else
{
data = GetRandomElementInArray(StrTok(GetDvar("mapvote_default_rotation_maps"), ":"));
dataSplitted = StrTok(data, ",");
modeCfg = dataSplitted[1];
mapName = GetMapCodeName(dataSplitted[0]);
}
SetDvar("sv_maprotationcurrent", "exec " + modeCfg + ".cfg map " + mapName);
SetDvar("sv_maprotation", "exec " + modeCfg + ".cfg map " + mapName);
}
DoRotation()
{
if (ShouldRotateDefault())
{
RotateDefault();
}
else
{
StartVote();
ListenForEndVote();
}
}
/* HUD section */

View File

@ -14,19 +14,19 @@ OnKillcamEnd()
{
if (isRoundBased() && !wasLastRound())
return false;
wait GetDvarInt("mapvote_display_wait_time");
[[level.mapvote_start_function]]();
[[level.mapvote_end_function]]();
wait GetDvarInt("mapvote_display_wait_time");
[[level.mapvote_rotate_function]]();
return false;
}
level waittill("final_killcam_done");
if (isRoundBased() && !wasLastRound())
return true;
wait GetDvarInt("mapvote_display_wait_time");
[[level.mapvote_start_function]]();
[[level.mapvote_end_function]]();
wait GetDvarInt("mapvote_display_wait_time");
[[level.mapvote_rotate_function]]();
return true;
}

View File

@ -35,8 +35,7 @@ OnIntermissionStart()
wait GetDvarInt("mapvote_display_wait_time");
[[level.mapvote_start_function]]();
[[level.mapvote_end_function]]();
[[level.mapvote_rotate_function]]();
for (i = 0; i < level.players.size; i++)
{