Skip to content

Commit

Permalink
Added Config
Browse files Browse the repository at this point in the history
"show-announcer-delay": 0,                // delay before announcer is visible in seconds
"announcer-visible-for-time": 10,       //how long will announcer be visible for in seconds
  • Loading branch information
audiomaster99 authored Mar 3, 2024
1 parent 2c4c6cd commit d45893c
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions BombsiteAnnouncer.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
using CounterStrikeSharp.API;
using System.Text.Json.Serialization;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Utils;
using Microsoft.Extensions.Logging;

namespace BombsiteAnnouncer;

public partial class BombsiteAnnouncer : BasePlugin
public class Config : BasePluginConfig
{
[JsonPropertyName("show-announcer-delay")]
public float ShowAnnouncerDelay { get; set; } = 5.0f;
[JsonPropertyName("announcer-visible-for-time")]
public float AnnouncerVisibleForTime { get; set; } = 10.0f;
}
public partial class BombsiteAnnouncer : BasePlugin, IPluginConfig<Config>
{
public override string ModuleName => "BombsiteAnnouncer";
public override string ModuleAuthor => "audio_brutalci";
public override string ModuleDescription => "Simple bombsite announcer";
public override string ModuleVersion => "V. 0.0.1";

public required Config Config { get; set; }
public bool bombsiteAnnouncer;
public string? _site;
public string? bombsite;
Expand All @@ -39,6 +47,10 @@ public override void Load(bool hotReload)
}
});
}
public void OnConfigParsed(Config config)
{
Config = config;
}
private void OnTick(CCSPlayerController player)
{
if (player.Team == CsTeam.CounterTerrorist)
Expand Down Expand Up @@ -110,8 +122,11 @@ static bool IsConnected(CCSPlayerController? player)
}
public void ShowAnnouncer()
{
bombsiteAnnouncer = true;
AddTimer(10.0f, () => { bombsiteAnnouncer = false; });
AddTimer(Config.ShowAnnouncerDelay, () =>
{
bombsiteAnnouncer = true;
AddTimer(Config.AnnouncerVisibleForTime, () => { bombsiteAnnouncer = false; });
});
}
// Credits B3none
public static int GetCurrentNumPlayers(CsTeam? csTeam = null)
Expand Down

0 comments on commit d45893c

Please sign in to comment.