mapvote 1.0.3

Changed modes mode name and cfg name separator from semi-colon (;) to comma (,) since the semi-colon seems to not be parsed properly when set through a cfg file

Added more debugging prints:
- Most voted map votes and index
- Most voted map votes and index
- Final map name, mode name and mode cfg just before rotation, all separated in multiple prints to detect any empty/wrong string

Removed old comments
This commit is contained in:
Resxt 2022-10-21 22:53:44 +02:00
parent 2dc19c0040
commit 0ed53a1b8c
3 changed files with 40 additions and 27 deletions

View File

@ -50,7 +50,7 @@ Here are the dvars you can configure:
| mapvote_enable | Toggle whether the mapvote is activated or not. 0 is off and 1 is on | 0 | 0 or 1 | | mapvote_enable | Toggle whether the mapvote is activated or not. 0 is off and 1 is on | 0 | 0 or 1 |
| mapvote_debug | Toggle whether the mapvote runs in debug mode or not. This will display the mapvote menu a few seconds after starting the game. 0 is off and 1 is on | 0 | 0 or 1 | | mapvote_debug | Toggle whether the mapvote runs in debug mode or not. This will display the mapvote menu a few seconds after starting the game. 0 is off and 1 is on | 0 | 0 or 1 |
| mapvote_maps | A list of the maps that are available for rotation. Each map name needs to start with a capitalized letter and each map is separated with : | Every BO2 maps including DLC maps | Any map name, starting with a capitalized letter and separated with a colon (:) | | mapvote_maps | A list of the maps that are available for rotation. Each map name needs to start with a capitalized letter and each map is separated with : | Every BO2 maps including DLC maps | Any map name, starting with a capitalized letter and separated with a colon (:) |
| mapvote_modes | A list of the modes that are available for rotation. The first parameter is how the mode will be displayed, it can be set to anything you like, the second parameter is the name of the cfg file to load found in the gamesettings folder | "Team Deathmatch;tdm:Domination;dom:Hardpoint;koth" | Any name you want followed by a semi-colon (;) with the cfg name and separated with a colon (:) | | mapvote_modes | A list of the modes that are available for rotation. The first parameter is how the mode will be displayed, it can be set to anything you like, the second parameter is the name of the cfg file to load found in the gamesettings folder | "Team Deathmatch,tdm:Domination,dom:Hardpoint,koth" | Any name you want followed by a comma (,) with the cfg name and separated with a colon (:) |
| mapvote_colors_selected | The color of the text when hovered or selected. This is also the color of the votes count | "blue" | red, green, yellow, blue, cyan, purple, white, grey, gray, black | | mapvote_colors_selected | The color of the text when hovered or selected. This is also the color of the votes count | "blue" | red, green, yellow, blue, cyan, purple, white, grey, gray, black |
| mapvote_colors_unselected | The color of the text when not hovered and not selected | "white" | red, green, yellow, blue, cyan, purple, white, grey, gray, black | | mapvote_colors_unselected | The color of the text when not hovered and not selected | "white" | red, green, yellow, blue, cyan, purple, white, grey, gray, black |
| mapvote_colors_timer | The color of the timer as long as it has more than 5 seconds remaining | "blue" | red, green, yellow, blue, cyan, purple, white, grey, gray, black | | mapvote_colors_timer | The color of the timer as long as it has more than 5 seconds remaining | "blue" | red, green, yellow, blue, cyan, purple, white, grey, gray, black |
@ -69,20 +69,20 @@ Below is an example CFG showing how each dvars can be configured.
The values you see are the default values that will be used if you don't set a dvar. The values you see are the default values that will be used if you don't set a dvar.
```c ```c
set "mapvote_enable" 1 set mapvote_enable 1
set "mapvote_maps" "Aftermath:Cargo:Carrier:Drone:Express:Hijacked:Meltdown:Overflow:Plaza:Raid:Slums:Standoff:Turbine:Yemen:Nuketown:Downhill:Mirage:Hydro:Grind:Encore:Magma:Vertigo:Studio:Uplink:Detour:Cove:Rush:Dig:Frost:Pod:Takeoff" set mapvote_maps "Aftermath:Cargo:Carrier:Drone:Express:Hijacked:Meltdown:Overflow:Plaza:Raid:Slums:Standoff:Turbine:Yemen:Nuketown:Downhill:Mirage:Hydro:Grind:Encore:Magma:Vertigo:Studio:Uplink:Detour:Cove:Rush:Dig:Frost:Pod:Takeoff"
set "mapvote_modes" "Team Deathmatch;tdm:Domination;dom:Hardpoint;koth" set mapvote_modes "Team Deathmatch,tdm:Domination,dom:Hardpoint,koth"
set "mapvote_colors_selected" "blue" set mapvote_colors_selected "blue"
set "mapvote_colors_unselected" "white" set mapvote_colors_unselected "white"
set "mapvote_colors_timer" "blue" set mapvote_colors_timer "blue"
set "mapvote_colors_timer_low" "red" 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_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
``` ```
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
@ -91,12 +91,12 @@ Here are some pre-set values if you want to quickly copy/paste something
|---|---| |---|---|
| All base game maps | "Aftermath:Cargo:Carrier:Drone:Express:Hijacked:Meltdown:Overflow:Plaza:Raid:Slums:Standoff:Turbine:Yemen" | | All base game maps | "Aftermath:Cargo:Carrier:Drone:Express:Hijacked:Meltdown:Overflow:Plaza:Raid:Slums:Standoff:Turbine:Yemen" |
| All DLC maps | "Nuketown:Downhill:Mirage:Hydro:Grind:Encore:Magma:Vertigo:Studio:Uplink:Detour:Cove:Rush:Dig:Frost:Pod:Takeoff" | | All DLC maps | "Nuketown:Downhill:Mirage:Hydro:Grind:Encore:Magma:Vertigo:Studio:Uplink:Detour:Cove:Rush:Dig:Frost:Pod:Takeoff" |
| Classic modes | "Team Deathmatch;tdm:Domination;dom:Hardpoint;koth" | | Classic modes | "Team Deathmatch,tdm:Domination,dom:Hardpoint,koth" |
| Objective modes | "Demolition;dem:Headquaters;hq:Capture the Flag;ctf" | | Objective modes | "Demolition,dem:Headquaters,hq:Capture the Flag,ctf" |
| Alternative modes | "Kill Confirmed;conf:One Flag CTF;oneflag" | | Alternative modes | "Kill Confirmed,conf:One Flag CTF,oneflag" |
| Party modes | "Gun Game;gun:One in the Chamber;oic:Sharpshooter;shrp:Sticks & Stones;sas" | | Party modes | "Gun Game,gun:One in the Chamber,oic:Sharpshooter,shrp:Sticks & Stones,sas" |
| FFA 24/7 | "Free for All;dm" | | FFA 24/7 | "Free for All,dm" |
| SND 24/7 | "Search & Destroy;sd" | | SND 24/7 | "Search & Destroy,sd" |
### Notes ### Notes

Binary file not shown.

View File

@ -10,7 +10,6 @@
*/ */
#include maps\mp\gametypes\_hud_util; #include maps\mp\gametypes\_hud_util;
#include maps\mp\gametypes_zm\_hud_util;
#include common_scripts\utility; #include common_scripts\utility;
#include maps\mp\_utility; #include maps\mp\_utility;
@ -54,7 +53,7 @@ InitDvars()
SetDvarIfNotInitialized("mapvote_debug", false); SetDvarIfNotInitialized("mapvote_debug", false);
SetDvarIfNotInitialized("mapvote_maps", "Aftermath:Cargo:Carrier:Drone:Express:Hijacked:Meltdown:Overflow:Plaza:Raid:Slums:Standoff:Turbine:Yemen:Nuketown:Downhill:Mirage:Hydro:Grind:Encore:Magma:Vertigo:Studio:Uplink:Detour:Cove:Rush:Dig:Frost:Pod:Takeoff"); SetDvarIfNotInitialized("mapvote_maps", "Aftermath:Cargo:Carrier:Drone:Express:Hijacked:Meltdown:Overflow:Plaza:Raid:Slums:Standoff:Turbine:Yemen:Nuketown:Downhill:Mirage:Hydro:Grind:Encore:Magma:Vertigo:Studio:Uplink:Detour:Cove:Rush:Dig:Frost:Pod:Takeoff");
SetDvarIfNotInitialized("mapvote_modes", "Team Deathmatch;tdm:Domination;dom:Hardpoint;koth"); SetDvarIfNotInitialized("mapvote_modes", "Team Deathmatch,tdm:Domination,dom:Hardpoint,koth");
SetDvarIfNotInitialized("mapvote_colors_selected", "blue"); SetDvarIfNotInitialized("mapvote_colors_selected", "blue");
SetDvarIfNotInitialized("mapvote_colors_unselected", "white"); SetDvarIfNotInitialized("mapvote_colors_unselected", "white");
SetDvarIfNotInitialized("mapvote_colors_timer", "blue"); SetDvarIfNotInitialized("mapvote_colors_timer", "blue");
@ -209,11 +208,8 @@ ListenForVoteInputs()
CreateVoteMenu() CreateVoteMenu()
{ {
//level endon("game_ended");
spacing = 20; spacing = 20;
hudLastPosY = -(((level.mapvote["maps"]["by_index"].size + level.mapvote["modes"]["by_index"].size + 1) * spacing) / 2); hudLastPosY = -(((level.mapvote["maps"]["by_index"].size + level.mapvote["modes"]["by_index"].size + 1) * spacing) / 2);
//hudLastPosY = -100;
for (mapIndex = 0; mapIndex < level.mapvote["maps"]["by_index"].size; mapIndex++) for (mapIndex = 0; mapIndex < level.mapvote["maps"]["by_index"].size; mapIndex++)
{ {
@ -373,6 +369,13 @@ ListenForEndVote()
Print("[MAPVOTE] No vote for map. Chosen random map index: " + mostVotedMapIndex); Print("[MAPVOTE] No vote for map. Chosen random map index: " + mostVotedMapIndex);
} }
} }
else
{
if (GetDvarInt("mapvote_debug"))
{
Print("[MAPVOTE] Most voted map has " + mostVotedMapVotes + " votes. Most voted map index: " + mostVotedMapIndex);
}
}
if (mostVotedModeVotes == 0) if (mostVotedModeVotes == 0)
{ {
@ -383,6 +386,13 @@ ListenForEndVote()
Print("[MAPVOTE] No vote for mode. Chosen random mode index: " + mostVotedModeIndex); Print("[MAPVOTE] No vote for mode. Chosen random mode index: " + mostVotedModeIndex);
} }
} }
else
{
if (GetDvarInt("mapvote_debug"))
{
Print("[MAPVOTE] Most voted mode has " + mostVotedModeVotes + " votes. Most voted mode index: " + mostVotedModeIndex);
}
}
modeName = level.mapvote["modes"]["by_index"][mostVotedModeIndex]; modeName = level.mapvote["modes"]["by_index"][mostVotedModeIndex];
modeCfg = level.mapvote["modes"]["by_name"][level.mapvote["modes"]["by_index"][mostVotedModeIndex]]; modeCfg = level.mapvote["modes"]["by_name"][level.mapvote["modes"]["by_index"][mostVotedModeIndex]];
@ -390,6 +400,9 @@ ListenForEndVote()
if (GetDvarInt("mapvote_debug")) if (GetDvarInt("mapvote_debug"))
{ {
Print("[MAPVOTE] mapName: " + mapName);
Print("[MAPVOTE] modeName: " + modeName);
Print("[MAPVOTE] modeCfg: " + modeCfg);
Print("[MAPVOTE] Rotating to " + mapName + " | " + modeName + " (" + modeCfg + ".cfg)"); Print("[MAPVOTE] Rotating to " + mapName + " | " + modeName + " (" + modeCfg + ".cfg)");
} }
@ -431,7 +444,7 @@ SetMapvoteData(type)
foreach (mode in GetRandomUniqueElementsInArray(availableElements, limit)) foreach (mode in GetRandomUniqueElementsInArray(availableElements, limit))
{ {
splittedMode = StrTok(mode, ";"); splittedMode = StrTok(mode, ",");
finalElements = AddElementToArray(finalElements, splittedMode[0]); finalElements = AddElementToArray(finalElements, splittedMode[0]);
level.mapvote["modes"]["by_name"][splittedMode[0]] = splittedMode[1]; level.mapvote["modes"]["by_name"][splittedMode[0]] = splittedMode[1];