Skip to content

Commit

Permalink
Added new config for RockTheVote
Browse files Browse the repository at this point in the history
- [RTV] Fixed an error that prevent the map from being changed at the end of voting when no votes were cast.
  • Loading branch information
FEDERICOMB96 committed Feb 11, 2024
1 parent 59ce18c commit 29976fd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 42 deletions.
9 changes: 5 additions & 4 deletions addons/amxmodx/configs/multimod_manager/configs.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@

"rockthevote":
{
"enable": true, // true / false
"cooldown": 120, // min = 0 (disabled)
"minplayers": 3, // min = 0 (disabled) | max = 32
"percentage": 75 // min = 0 (disabled) | max = 100
"enable": true, // true / false
"cooldown": 120, // min = 0 (disabled)
"minplayers": 3, // min = 0 (disabled) | max = 32
"percentage": 75, // min = 0 (disabled) | max = 100
"ignore_change_map_type": true // true / false (true = ignores the change_map_type of the mod)
},

"nomination":
Expand Down
1 change: 1 addition & 0 deletions addons/amxmodx/scripting/include/mm_incs/defines.inc
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ enum GlobalConfigs_e
RTV_Cooldown,
RTV_MinPlayers,
RTV_Percentage,
bool:RTV_IgnoreChangeMapType,

// Nomination
bool:Nom_Mods_Enabled,
Expand Down
56 changes: 18 additions & 38 deletions addons/amxmodx/scripting/include/mm_incs/mapchooser.inc
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ MapChooser_InitNextVoteMap(iStartVote)
MapChooser_ResetAllData();
Nominations_ResetAllData();

g_bSelectedNextMap = true;

if(g_bIsRockTheVote)
{
RockTheVoteSendIntermission();
return;
}

g_iChangeMapTime = 10;

ExecChangeTimeleft();
return;
}
Expand Down Expand Up @@ -262,16 +252,6 @@ public OnTask_CheckVoteMap()
MapChooser_ResetAllData();
Nominations_ResetAllData();

g_bSelectedNextMap = true;

if(g_bIsRockTheVote)
{
RockTheVoteSendIntermission();
return;
}

g_iChangeMapTime = 10;

ExecChangeTimeleft();
}
else
Expand All @@ -287,10 +267,6 @@ public OnTask_CheckVoteMap()
MapChooser_ResetAllData();
Nominations_ResetAllData();

g_bSelectedNextMap = true;

g_iChangeMapTime = 10;

ExecChangeTimeleft();
}
}
Expand Down Expand Up @@ -415,16 +391,6 @@ public OnTask_CheckVoteMapFIX()
MapChooser_ResetAllData();
Nominations_ResetAllData();

g_bSelectedNextMap = true;

if(g_bIsRockTheVote)
{
RockTheVoteSendIntermission();
return;
}

g_iChangeMapTime = 10;

ExecChangeTimeleft();
}
else
Expand All @@ -440,10 +406,6 @@ public OnTask_CheckVoteMapFIX()
MapChooser_ResetAllData();
Nominations_ResetAllData();

g_bSelectedNextMap = true;

g_iChangeMapTime = 10;

ExecChangeTimeleft();
}
}
Expand Down Expand Up @@ -569,8 +531,26 @@ public OnTask_ChangeMap(sMap[])

ExecChangeTimeleft()
{
g_bSelectedNextMap = true;

remove_task(TASK_TIMELEFT);

if(g_bIsRockTheVote)
{
// Change map instantly if the ignore change map type is true or the change map type is timeleft
if(g_GlobalConfigs[RTV_IgnoreChangeMapType] || UTIL_GetChangeMapType(g_iCurrentMod) == CHANGEMAP_TIMELEFT)
{
RockTheVoteSendIntermission();
return;
}

// Change map at the end of the round or one more round
OnTask_ChangeTimeLeft();
return;
}

g_iChangeMapTime = 10;

(UTIL_GetChangeMapType(g_iCurrentMod) == CHANGEMAP_TIMELEFT)
? set_task((float(get_timeleft()) - 10.1), "OnTask_AlertChangeMap", TASK_TIMELEFT)
: set_task((float(get_timeleft()) - 1.1), "OnTask_ChangeTimeLeft", TASK_TIMELEFT);
Expand Down
1 change: 1 addition & 0 deletions addons/amxmodx/scripting/multimod_manager.sma
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ MultiMod_Init()
g_GlobalConfigs[RTV_Cooldown] = max(0, json_object_get_number(jConfigsFile, "rockthevote.cooldown", true));
g_GlobalConfigs[RTV_MinPlayers] = clamp(json_object_get_number(jConfigsFile, "rockthevote.minplayers", true), 0, MAX_CLIENTS);
g_GlobalConfigs[RTV_Percentage] = clamp(json_object_get_number(jConfigsFile, "rockthevote.percentage", true), 0, 100);
g_GlobalConfigs[RTV_IgnoreChangeMapType] = json_object_get_bool(jConfigsFile, "rockthevote.ignore_change_map_type", true);
g_GlobalConfigs[Nom_Mods_Enabled] = json_object_get_bool(jConfigsFile, "nomination.mods", true);
g_GlobalConfigs[Nom_Maps_Enabled] = json_object_get_bool(jConfigsFile, "nomination.maps", true);
g_GlobalConfigs[AdminMaxOptionsInMenu] = clamp(json_object_get_number(jConfigsFile, "admin_max_options_in_menu"), 2, MAX_ADMIN_VOTEOPTIONS);
Expand Down

0 comments on commit 29976fd

Please sign in to comment.