Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions MapChooserSharp/Util/TimeLeftUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Translations;
using CounterStrikeSharp.API.Modules.Cvars;
using CounterStrikeSharp.API.Modules.Cvars.Validators;
using CounterStrikeSharp.API.Modules.Entities;
using MapChooserSharp.API.MapVoteController;
using MapChooserSharp.Interfaces;
Expand All @@ -17,6 +18,10 @@ internal sealed class TimeLeftUtil(IServiceProvider serviceProvider, bool hotRel
public override string PluginModuleName => "TimeleftUtil";
public override string ModuleChatPrefix => "unused";
protected override bool UseTranslationKeyInModuleChatPrefix => false;

public readonly FakeConVar<int> MapTimeTypeOverride = new("mcs_map_time_type_override",
"Override map time type. 0 = automatic detection, 1 = mp_timelimit, 2 = mp_maxrounds, 3 = mp_roundtime", 0,
ConVarFlags.FCVAR_NONE, new RangeValidator<int>(0, 3));

public override void RegisterServices(IServiceCollection services)
{
Expand All @@ -25,6 +30,7 @@ public override void RegisterServices(IServiceCollection services)

protected override void OnInitialize()
{
TrackConVar(MapTimeTypeOverride);
if (hotReload)
{
ReDetermineExtendType();
Expand Down Expand Up @@ -145,7 +151,7 @@ public int RoundTimeLeft

public bool ExtendTimeLimit(int minutes)
{
if (TimeLimit < 1)
if (TimeLimit < 1 && MapTimeTypeOverride.Value == 0)
{
DebugLogger.LogWarning("TimeLeft util tried to extend a time limit, but looks like current game mode is not a time limit based! aborting...");
return false;
Expand Down Expand Up @@ -173,7 +179,7 @@ public bool ExtendTimeLimit(int minutes)

public bool ExtendRounds(int rounds)
{
if (RoundsLeft < 1)
if (RoundsLeft < 1 && MapTimeTypeOverride.Value == 0)
{
DebugLogger.LogWarning("TimeLeft util tried to extend a max rounds, but looks like current game mode is not a round based! aborting...");
return false;
Expand Down Expand Up @@ -201,7 +207,7 @@ public bool ExtendRounds(int rounds)

public bool ExtendRoundTime(int minutes)
{
if (RoundTimeLeft < 1)
if (RoundTimeLeft < 1 && MapTimeTypeOverride.Value == 0)
{
DebugLogger.LogWarning("TimeLeft util tried to extend a round time limit, but looks like current game mode is not a round time limit based! aborting...");
return false;
Expand Down Expand Up @@ -313,6 +319,9 @@ public string GetFormattedRoundsLeft(int roundsLeft, CCSPlayerController? player

private McsMapExtendType DetermineExtendType()
{
if (MapTimeTypeOverride.Value > 0)
return (McsMapExtendType)MapTimeTypeOverride.Value - 1;

if (TimeLimit > 0)
return McsMapExtendType.TimeLimit;

Expand Down
9 changes: 8 additions & 1 deletion docs/en/configuration/CONVAR.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,11 @@ ConVar configuration file is located in `game/csgo/cfg/MapChooserSharp/convars.c
| mcs_rtv_command_unlock_time_map_extend | Seconds to take unlock RTV command after map is extended in vote | 120.0 | Valid Range is 0.0 - 1200.0 |
| mcs_rtv_command_unlock_time_map_start | Seconds to take unlock RTV command after map started | 300.0 | Valid Range is 0.0 - 1200.0 |
| mcs_rtv_vote_start_threshold | How many percent to require start rtv vote? | 0.5 | Valid Range is 0.0 - 1.0 |
| mcs_rtv_map_change_timing | Seconds to change map after RTV is success. Set 0.0 to change immediately | 3.0 | Valid Range is 0.0 - 60.0 |
| mcs_rtv_map_change_timing | Seconds to change map after RTV is success. Set 0.0 to change immediately | 3.0 | Valid Range is 0.0 - 60.0 |


## Timeleft Util

| ConVar | Description | Default Value | note |
|-----------------------------|--------------------------------------------------------------------------------------------------------|---------------|------------------------------------------------------------------------------------------------|
| mcs_map_time_type_override | Override map time type. 0 = automatic detection, 1 = mp_timelimit, 2 = mp_maxrounds, 3 = mp_roundtime | 0 | You should set correspond CVars correctly when using override, otherwise plugin will not work. |
9 changes: 8 additions & 1 deletion docs/ja/configuration/CONVAR.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,11 @@ ConVarのコンフィグファイルは `game/csgo/cfg/MapChooserSharp/convars.c
| mcs_rtv_command_unlock_time_map_extend | マップの延長が決まってからRTV出来るようになるまでの秒数 | 120.0 | 有効な範囲: 0.0 - 1200.0 |
| mcs_rtv_command_unlock_time_map_start | マップがスタートしてからRTV出来るようになるまでの秒数 | 300.0 | 有効な範囲: 0.0 - 1200.0 |
| mcs_rtv_vote_start_threshold | RTV投票を始めるために必要な投票率 | 0.5 | 有効な範囲: 0.0 - 1.0 |
| mcs_rtv_map_change_timing | RTV完了後にマップを変更するまでの時間 (秒で指定) | 3.0 | 有効な範囲: 0.0 - 60.0 |
| mcs_rtv_map_change_timing | RTV完了後にマップを変更するまでの時間 (秒で指定) | 3.0 | 有効な範囲: 0.0 - 60.0 |


## Timeleft Util

| ConVar | Description | Default Value | note |
|-----------------------------|-------------------------------------------------------------------------------|---------------|-------------------------------------------------------------------|
| mcs_map_time_type_override | マップタイプを上書きします. 0 = 自動検出, 1 = mp_timelimit, 2 = mp_maxrounds, 3 = mp_roundtime | 0 | オーバーライドを使用する際は対応するCVarを正しく設定する必要があります。正しく設定されていない場合、プラグインは動作しません。 |