mapvote 1.1.0

Added mapvote_sounds_menu_enabled dvar.
You can now enable or disable the sounds playing in the menu when selecting an item, moving up or down and canceling a choice

Added mapvote_sounds_timer_enabled dvar.
You can now choose if the timer will start beeping when there's only 5s left or not

Added mapvote_display_wait_time dvar.
Changed the wait time before displaying the menu from 3s to a configurable dvar

Replace most level.mapvote variables with GetDvar instead to avoid setting too much variables when we can simply retrieve the dvar value (try to avoid hitting the variable limit that the game has)

Replace start notify and end function listener with a direct with direct function calls for better compatibility for future updates
This commit is contained in:
Resxt 2022-10-25 16:30:07 +02:00
parent 0b0b4620f1
commit ff74d9561c
5 changed files with 72 additions and 53 deletions

View File

@ -58,10 +58,13 @@ Here are the dvars you can configure:
| mapvote_colors_help_text | The color of the help text at the bottom explaining how to use the menu | "white" | red, green, yellow, blue, cyan, purple, white, grey, gray, black | | mapvote_colors_help_text | The color of the help text at the bottom explaining how to use the menu | "white" | red, green, yellow, blue, cyan, purple, white, grey, gray, black |
| mapvote_colors_help_accent | The color of the accented text of the help text at the bottom | "blue" | red, green, yellow, blue, cyan, purple, white, grey, gray, black | | mapvote_colors_help_accent | The color of the accented text of the help text at the bottom | "blue" | red, green, yellow, blue, cyan, purple, white, grey, gray, black |
| mapvote_colors_help_accent_mode | The accenting mode for the help text. `standard` only puts the accent color on the button to press and `max` puts it on both the buttons and the action it does | "standard" | standard or max | | mapvote_colors_help_accent_mode | The accenting mode for the help text. `standard` only puts the accent color on the button to press and `max` puts it on both the buttons and the action it does | "standard" | standard or max |
| mapvote_sounds_menu_enabled | Toggle whether the mapvote menu sounds are enabled or not. 0 is off and 1 is on | 1 | 0 or 1 |
| mapvote_sounds_timer_enabled | Toggle whether the timer will start making a beeping sound every second when there's 5 or less seconds remaining to vote or not. 0 is off and 1 is on | 1 | 0 or 1 |
| mapvote_vote_time | The time the vote lasts (in seconds) | 30 | Any plain number above 5 | | mapvote_vote_time | The time the vote lasts (in seconds) | 30 | Any plain number above 5 |
| mapvote_blur_level | The amount of blur to put at the end of the killcam. The max recommended value is 5. 0 disables it | 2.5 | Any number | | mapvote_blur_level | The amount of blur to put at the end of the killcam. The max recommended value is 5. 0 disables it | 2.5 | Any number |
| 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_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 your map and modes length so that it doesn't overlap with the vote counts | 75 | Any plain 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 your map and modes 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 after the killcam ends (in seconds) | 1 | 0.05 or above |
### Configuration ### Configuration
@ -79,10 +82,13 @@ set mapvote_colors_timer_low "red"
set mapvote_colors_help_text "white" set mapvote_colors_help_text "white"
set mapvote_colors_help_accent "blue" set mapvote_colors_help_accent "blue"
set mapvote_colors_help_accent_mode "standard" set mapvote_colors_help_accent_mode "standard"
set mapvote_sounds_menu_enabled 1
set mapvote_sounds_timer_enabled 1
set mapvote_vote_time 30 set mapvote_vote_time 30
set mapvote_blur_level 2.5 set mapvote_blur_level 2.5
set mapvote_blur_fade_in_time 2 set mapvote_blur_fade_in_time 2
set mapvote_horizontal_spacing 75 set mapvote_horizontal_spacing 75
set mapvote_display_wait_time 1
``` ```
Here are some pre-set values if you want to quickly copy/paste something Here are some pre-set values if you want to quickly copy/paste something
@ -100,9 +106,12 @@ Here are some pre-set values if you want to quickly copy/paste something
### Notes ### Notes
- If right click is set to toggle ads then pressing right click will make the player go up by one every 0.35s. If I didn't change it to be that way players with toggle ads would have to press right click twice to go up by one all the time. Now instead they simply right click once to start going up and right click again to stop. - If right click is set to toggle ads then pressing right click will make the player go up by one every 0.35s.
If I didn't change it to be that way players with toggle ads would have to press right click twice to go up by one all the time.
Now instead they simply right click once to start going up and right click again to stop.
- When two maps/modes have the same votes, the lowest one in the list will win. In the future it would be nice to randomize between both - When two maps/modes have the same votes, the lowest one in the list will win. In the future it would be nice to randomize between both
- Ending the game with ESC doesn't work when in debug mode. Use `map_restart` in the console when your script is compiled. And if you want to leave use `disconnect` in the console until this is fixed - Ending the game with ESC doesn't work when in debug mode.
Use `map_restart` in the console when your script is compiled. And if you want to leave use `disconnect` in the console until this is fixed
- When there's only one map/mode the right map/mode will be chosen but adding an option to hide single vote elements would be nice - When there's only one map/mode the right map/mode will be chosen but adding an option to hide single vote elements would be nice
## mapvote_mp_extend.gsc ## mapvote_mp_extend.gsc

Binary file not shown.

Binary file not shown.

View File

@ -20,6 +20,9 @@ Init()
{ {
if (GetDvarInt("mapvote_enable")) if (GetDvarInt("mapvote_enable"))
{ {
level.mapvote_start_function = ::StartVote;
level.mapvote_end_function = ::ListenForEndVote;
InitMapvote(); InitMapvote();
} }
} }
@ -33,14 +36,12 @@ InitMapvote()
InitDvars(); InitDvars();
InitVariables(); InitVariables();
level thread ListenForStartVote();
level thread ListenForEndVote();
if (GetDvarInt("mapvote_debug")) if (GetDvarInt("mapvote_debug"))
{ {
Print("[MAPVOTE] Debug mode is ON"); Print("[MAPVOTE] Debug mode is ON");
wait 3; wait 3;
level notify("mapvote_vote_start"); level thread StartVote();
level thread ListenForEndVote();
} }
else else
{ {
@ -62,29 +63,19 @@ InitDvars()
SetDvarIfNotInitialized("mapvote_colors_help_text", "white"); SetDvarIfNotInitialized("mapvote_colors_help_text", "white");
SetDvarIfNotInitialized("mapvote_colors_help_accent", "blue"); SetDvarIfNotInitialized("mapvote_colors_help_accent", "blue");
SetDvarIfNotInitialized("mapvote_colors_help_accent_mode", "standard"); SetDvarIfNotInitialized("mapvote_colors_help_accent_mode", "standard");
SetDvarIfNotInitialized("mapvote_sounds_menu_enabled", 1);
SetDvarIfNotInitialized("mapvote_sounds_timer_enabled", 1);
SetDvarIfNotInitialized("mapvote_vote_time", 30); SetDvarIfNotInitialized("mapvote_vote_time", 30);
SetDvarIfNotInitialized("mapvote_blur_level", 2.5); SetDvarIfNotInitialized("mapvote_blur_level", 2.5);
SetDvarIfNotInitialized("mapvote_blur_fade_in_time", 2); SetDvarIfNotInitialized("mapvote_blur_fade_in_time", 2);
SetDvarIfNotInitialized("mapvote_horizontal_spacing", 75); SetDvarIfNotInitialized("mapvote_horizontal_spacing", 75);
SetDvarIfNotInitialized("mapvote_display_wait_time", 1);
} }
InitVariables() InitVariables()
{ {
SetMapvoteData("map"); SetMapvoteData("map");
SetMapvoteData("mode"); SetMapvoteData("mode");
level.mapvote["vote_time"] = GetDvarInt("mapvote_vote_time");
level.mapvote["colors"]["unselected"] = GetGscColor(GetDvar("mapvote_colors_unselected"));
level.mapvote["colors"]["selected"] = GetGscColor(GetDvar("mapvote_colors_selected"));
level.mapvote["colors"]["timer"] = GetGscColor(GetDvar("mapvote_colors_timer"));
level.mapvote["colors"]["timer_low"] = GetGscColor(GetDvar("mapvote_colors_timer_low"));
level.mapvote["colors"]["help_text"] = GetChatColor(GetDvar("mapvote_colors_help_text"));
level.mapvote["colors"]["help_accent"] = GetChatColor(GetDvar("mapvote_colors_help_accent"));
level.mapvote["colors"]["help_accent_mode"] = GetDvar("mapvote_colors_help_accent_mode");
level.mapvote["blur_level"] = GetDvarInt("mapvote_blur_level");
level.mapvote["blur_fade_in_time"] = GetDvarInt("mapvote_blur_fade_in_time");
level.mapvote["horizontal_spacing"] = GetDvarInt("mapvote_horizontal_spacing");
level.mapvote["vote"]["maps"] = []; level.mapvote["vote"]["maps"] = [];
level.mapvote["vote"]["modes"] = []; level.mapvote["vote"]["modes"] = [];
@ -148,7 +139,11 @@ ListenForVoteInputs()
{ {
if (self.mapvote[section]["hovered_index"] < (level.mapvote[section + "s"]["by_index"].size - 1)) if (self.mapvote[section]["hovered_index"] < (level.mapvote[section + "s"]["by_index"].size - 1))
{ {
self playlocalsound("uin_start_count_down"); if (GetDvarInt("mapvote_sounds_menu_enabled"))
{
self playlocalsound("uin_start_count_down");
}
self UpdateSelection(section, (self.mapvote[section]["hovered_index"] + 1)); self UpdateSelection(section, (self.mapvote[section]["hovered_index"] + 1));
} }
} }
@ -156,20 +151,32 @@ ListenForVoteInputs()
{ {
if (self.mapvote[section]["hovered_index"] > 0) if (self.mapvote[section]["hovered_index"] > 0)
{ {
self playlocalsound("uin_start_count_down"); if (GetDvarInt("mapvote_sounds_menu_enabled"))
{
self playlocalsound("uin_start_count_down");
}
self UpdateSelection(section, (self.mapvote[section]["hovered_index"] - 1)); self UpdateSelection(section, (self.mapvote[section]["hovered_index"] - 1));
} }
} }
else if (input == "mapvote_select") else if (input == "mapvote_select")
{ {
self playlocalsound("mpl_killconfirm_tags_pickup"); if (GetDvarInt("mapvote_sounds_menu_enabled"))
{
self playlocalsound("mpl_killconfirm_tags_pickup");
}
self ConfirmSelection(section); self ConfirmSelection(section);
} }
else if (input == "mapvote_unselect") else if (input == "mapvote_unselect")
{ {
if (section != "map") if (section != "map")
{ {
self playlocalsound("fly_betty_jump"); if (GetDvarInt("mapvote_sounds_menu_enabled"))
{
self playlocalsound("fly_betty_jump");
}
self CancelSelection(section); self CancelSelection(section);
} }
} }
@ -214,14 +221,14 @@ CreateVoteMenu()
for (mapIndex = 0; mapIndex < level.mapvote["maps"]["by_index"].size; mapIndex++) for (mapIndex = 0; mapIndex < level.mapvote["maps"]["by_index"].size; mapIndex++)
{ {
mapVotesHud = CreateHudText("", "objective", 1.5, "LEFT", "CENTER", level.mapvote["horizontal_spacing"], hudLastPosY, true, 0); mapVotesHud = CreateHudText("", "objective", 1.5, "LEFT", "CENTER", GetDvarInt("mapvote_horizontal_spacing"), hudLastPosY, true, 0);
mapVotesHud.color = level.mapvote["colors"]["selected"]; mapVotesHud.color = GetGscColor(GetDvar("mapvote_colors_selected"));
level.mapvote["hud"]["maps"][mapIndex] = mapVotesHud; level.mapvote["hud"]["maps"][mapIndex] = mapVotesHud;
foreach (player in GetHumanPlayers()) foreach (player in GetHumanPlayers())
{ {
player.mapvote["map"][mapIndex]["hud"] = player CreateHudText(level.mapvote["maps"]["by_index"][mapIndex], "objective", 1.5, "LEFT", "CENTER", -level.mapvote["horizontal_spacing"], hudLastPosY); player.mapvote["map"][mapIndex]["hud"] = player CreateHudText(level.mapvote["maps"]["by_index"][mapIndex], "objective", 1.5, "LEFT", "CENTER", -(GetDvarInt("mapvote_horizontal_spacing")), hudLastPosY);
if (mapIndex == 0) if (mapIndex == 0)
{ {
@ -240,14 +247,14 @@ CreateVoteMenu()
for (modeIndex = 0; modeIndex < level.mapvote["modes"]["by_index"].size; modeIndex++) for (modeIndex = 0; modeIndex < level.mapvote["modes"]["by_index"].size; modeIndex++)
{ {
modeVotesHud = CreateHudText("", "objective", 1.5, "LEFT", "CENTER", level.mapvote["horizontal_spacing"], hudLastPosY, true, 0); modeVotesHud = CreateHudText("", "objective", 1.5, "LEFT", "CENTER", GetDvarInt("mapvote_horizontal_spacing"), hudLastPosY, true, 0);
modeVotesHud.color = level.mapvote["colors"]["selected"]; modeVotesHud.color = GetGscColor(GetDvar("mapvote_colors_selected"));
level.mapvote["hud"]["modes"][modeIndex] = modeVotesHud; level.mapvote["hud"]["modes"][modeIndex] = modeVotesHud;
foreach (player in GetHumanPlayers()) foreach (player in GetHumanPlayers())
{ {
player.mapvote["mode"][modeIndex]["hud"] = player CreateHudText(level.mapvote["modes"]["by_index"][modeIndex], "objective", 1.5, "LEFT", "CENTER", -level.mapvote["horizontal_spacing"], hudLastPosY); player.mapvote["mode"][modeIndex]["hud"] = player CreateHudText(level.mapvote["modes"]["by_index"][modeIndex], "objective", 1.5, "LEFT", "CENTER", -(GetDvarInt("mapvote_horizontal_spacing")), hudLastPosY);
SetElementUnselected(player.mapvote["mode"][modeIndex]["hud"]); SetElementUnselected(player.mapvote["mode"][modeIndex]["hud"]);
} }
@ -262,24 +269,24 @@ CreateVoteMenu()
buttonsHelpMessage = ""; buttonsHelpMessage = "";
if (level.mapvote["colors"]["help_accent_mode"] == "standard") if (GetDvar("mapvote_colors_help_accent_mode") == "standard")
{ {
buttonsHelpMessage = level.mapvote["colors"]["help_text"] + "Press " + level.mapvote["colors"]["help_accent"] + "[{+attack}] " + level.mapvote["colors"]["help_text"] + "to go down - Press " + level.mapvote["colors"]["help_accent"] + "[{+speed_throw}] " + level.mapvote["colors"]["help_text"] + "to go up - Press " + level.mapvote["colors"]["help_accent"] + "[{+gostand}] " + level.mapvote["colors"]["help_text"] + "to select - Press " + level.mapvote["colors"]["help_accent"] + "[{+activate}] " + level.mapvote["colors"]["help_text"] + "to undo"; buttonsHelpMessage = GetChatColor(GetDvar("mapvote_colors_help_text")) + "Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+attack}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to go down - Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+speed_throw}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to go up - Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+gostand}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to select - Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+activate}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to undo";
} }
else if(level.mapvote["colors"]["help_accent_mode"] == "max") else if(GetDvar("mapvote_colors_help_accent_mode") == "max")
{ {
buttonsHelpMessage = level.mapvote["colors"]["help_text"] + "Press " + level.mapvote["colors"]["help_accent"] + "[{+attack}] " + level.mapvote["colors"]["help_text"] + "to go " + level.mapvote["colors"]["help_accent"] + "down " + level.mapvote["colors"]["help_text"] + "- Press " + level.mapvote["colors"]["help_accent"] + "[{+speed_throw}] " + level.mapvote["colors"]["help_text"] + "to go " + level.mapvote["colors"]["help_accent"] + "up " + level.mapvote["colors"]["help_text"] + "- Press " + level.mapvote["colors"]["help_accent"] + "[{+gostand}] " + level.mapvote["colors"]["help_text"] + "to " + level.mapvote["colors"]["help_accent"] + "select " + level.mapvote["colors"]["help_text"] + "- Press " + level.mapvote["colors"]["help_accent"] + "[{+activate}] " + level.mapvote["colors"]["help_text"] + "to " + level.mapvote["colors"]["help_accent"] + "undo"; buttonsHelpMessage = GetChatColor(GetDvar("mapvote_colors_help_text")) + "Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+attack}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to go " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "down " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "- Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+speed_throw}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to go " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "up " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "- Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+gostand}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "select " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "- Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+activate}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "undo";
} }
if (GetDvarInt("mapvote_debug")) if (GetDvarInt("mapvote_debug"))
{ {
if (level.mapvote["colors"]["help_accent_mode"] == "standard") if (GetDvar("mapvote_colors_help_accent_mode") == "standard")
{ {
buttonsHelpMessage = buttonsHelpMessage + " - Press " + level.mapvote["colors"]["help_accent"] + "[{+melee}] " + level.mapvote["colors"]["help_text"] + "to debug"; buttonsHelpMessage = buttonsHelpMessage + " - Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+melee}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to debug";
} }
else if(level.mapvote["colors"]["help_accent_mode"] == "max") else if(GetDvar("mapvote_colors_help_accent_mode") == "max")
{ {
buttonsHelpMessage = buttonsHelpMessage + level.mapvote["colors"]["help_text"] + " - Press " + level.mapvote["colors"]["help_accent"] + "[{+melee}] " + level.mapvote["colors"]["help_text"] + "to " + level.mapvote["colors"]["help_accent"] + "debug"; buttonsHelpMessage = buttonsHelpMessage + GetChatColor(GetDvar("mapvote_colors_help_text")) + " - Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+melee}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "debug";
} }
} }
@ -292,24 +299,27 @@ CreateVoteTimer()
soundFX = spawn("script_origin", (0,0,0)); soundFX = spawn("script_origin", (0,0,0));
soundFX hide(); soundFX hide();
timerhud = CreateTimer(level.mapvote["vote_time"], &"Vote ends in: ", "objective", 1.5, "CENTER", "CENTER", 0, -210); timerhud = CreateTimer(GetDvarInt("mapvote_vote_time"), &"Vote ends in: ", "objective", 1.5, "CENTER", "CENTER", 0, -210);
timerhud.color = level.mapvote["colors"]["timer"]; timerhud.color = GetGscColor(GetDvar("mapvote_colors_timer"));
for (i = level.mapvote["vote_time"]; i > 0; i--) for (i = GetDvarInt("mapvote_vote_time"); i > 0; i--)
{ {
if(i <= 5) if(i <= 5)
{ {
timerhud.color = level.mapvote["colors"]["timer_low"]; timerhud.color = GetGscColor(GetDvar("mapvote_colors_timer_low"));
soundFX playSound( "mpl_ui_timer_countdown" );
if (GetDvarInt("mapvote_sounds_timer_enabled"))
{
soundFX playSound( "mpl_ui_timer_countdown" );
}
} }
wait(1); wait(1);
} }
level notify("mapvote_vote_end"); level notify("mapvote_vote_end");
} }
ListenForStartVote() StartVote()
{ {
level endon("end_game"); level endon("end_game");
level waittill("mapvote_vote_start");
for (i = 0; i < level.mapvote["maps"]["by_index"].size; i++) for (i = 0; i < level.mapvote["maps"]["by_index"].size; i++)
{ {
@ -327,7 +337,7 @@ ListenForStartVote()
foreach (player in GetHumanPlayers()) foreach (player in GetHumanPlayers())
{ {
player FreezeControlsAllowLook(1); player FreezeControlsAllowLook(1);
player SetBlur(level.mapvote["blur_level"], level.mapvote["blur_fade_in_time"]); player SetBlur(GetDvarInt("mapvote_blur_level"), GetDvarInt("mapvote_blur_fade_in_time"));
player thread ListenForVoteInputs(); player thread ListenForVoteInputs();
} }
@ -535,12 +545,12 @@ CancelSelection(type)
SetElementSelected(element) SetElementSelected(element)
{ {
element.color = level.mapvote["colors"]["selected"]; element.color = GetGscColor(GetDvar("mapvote_colors_selected"));
} }
SetElementUnselected(element) SetElementUnselected(element)
{ {
element.color = level.mapvote["colors"]["unselected"]; element.color = GetGscColor(GetDvar("mapvote_colors_unselected"));
} }
CreateHudText(text, font, fontScale, relativeToX, relativeToY, relativeX, relativeY, isServer, value) CreateHudText(text, font, fontScale, relativeToX, relativeToY, relativeX, relativeY, isServer, value)

View File

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