Skip to content

Commit

Permalink
Ntf Announcement
Browse files Browse the repository at this point in the history
  • Loading branch information
Misfiy committed Oct 23, 2023
1 parent ec1bf36 commit 52d1a19
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 104 deletions.
8 changes: 7 additions & 1 deletion AutoBroadcast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class AutoBroadcast : Plugin<Config>
public override string Prefix => "AutoBroadcast";
public override string Author => "@misfiy";
public override Version RequiredExiledVersion => new(8, 2, 1);
public override Version Version => new(1, 5, 0);
public override Version Version => new(1, 5, 1);
private Handler eventHandler;
public static AutoBroadcast Instance;

Expand Down Expand Up @@ -38,6 +38,9 @@ public void RegisterEvents()
Exiled.Events.Handlers.Player.Verified += eventHandler.OnVerified;
Exiled.Events.Handlers.Player.Spawned += eventHandler.OnSpawned;

if(Instance.Config.NtfAnnouncementCassie != "DISABLED" && Instance.Config.NtfAnnouncementCassieNoScps != "DISABLED")
Exiled.Events.Handlers.Map.AnnouncingNtfEntrance += eventHandler.OnAnnouncingMtf;

Log.Debug("Events have been registered!");
}
public void UnregisterEvents()
Expand All @@ -48,6 +51,9 @@ public void UnregisterEvents()
Exiled.Events.Handlers.Player.Verified -= eventHandler.OnVerified;
Exiled.Events.Handlers.Player.Spawned -= eventHandler.OnSpawned;

if(Instance.Config.NtfAnnouncementCassie != "DISABLED" && Instance.Config.NtfAnnouncementCassieNoScps != "DISABLED")
Exiled.Events.Handlers.Map.AnnouncingNtfEntrance -= eventHandler.OnAnnouncingMtf;

eventHandler = null!;
}
}
Expand Down
4 changes: 3 additions & 1 deletion Config.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Exiled.API.Interfaces;
using PlayerRoles;
using System.ComponentModel;

namespace AutoBroadcastSystem
{
Expand All @@ -26,6 +25,9 @@ public sealed class Config : IConfig
},
};

public string NtfAnnouncementCassieNoScps { get; set; } = "DISABLED";
public string NtfAnnouncementCassie { get; set; } = "DISABLED";

public BroadCassie RoundStart { get; set; } = new()
{
Broadcast = new()
Expand Down
28 changes: 27 additions & 1 deletion Handler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ namespace AutoBroadcastSystem.Events
using Exiled.Events.EventArgs.Player;
using Exiled.Events.EventArgs.Server;
using AutoBroadcastSystem;
using static AutoBroadcastSystem.CoroutinesHandler;
using static CoroutinesHandler;
using Exiled.API.Features;
using MEC;
using Exiled.Events.EventArgs.Map;

public sealed class Handler
{
Expand Down Expand Up @@ -51,6 +52,31 @@ public void OnRespawningTeam(RespawningTeamEventArgs ev)
}
}

public void OnAnnouncingMtf(AnnouncingNtfEntranceEventArgs ev)
{
string cassieMessage = string.Empty;
if (ev.ScpsLeft == 0 && AutoBroadcast.Instance.Config.NtfAnnouncementCassieNoScps != "DISABLED")
{
ev.IsAllowed = false;
cassieMessage = AutoBroadcast.Instance.Config.NtfAnnouncementCassieNoScps;
}
else if (ev.ScpsLeft >= 1 && AutoBroadcast.Instance.Config.NtfAnnouncementCassie != "DISABLED")
{
ev.IsAllowed = false;
cassieMessage = AutoBroadcast.Instance.Config.NtfAnnouncementCassie;
}

cassieMessage = cassieMessage.Replace("%scps%", $"{ev.ScpsLeft} scpsubject");

if (ev.ScpsLeft > 1)
cassieMessage = cassieMessage.Replace("scpsubject", "scpsubjects");

cassieMessage = cassieMessage.Replace("%designation%", $"nato_{ev.UnitName[0]} {ev.UnitNumber}");

if (!string.IsNullOrEmpty(cassieMessage))
Cassie.Message(cassieMessage);
}

public void OnSpawned(SpawnedEventArgs ev)
{
if (config.SpawnBroadcasts.TryGetValue(ev.Player.Role.Type, out BroadCassie broadcast))
Expand Down
109 changes: 8 additions & 101 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,105 +1,12 @@
# AutoBroadcast ![Downloads](https://img.shields.io/github/downloads/Misfiy/AutoBroadcast/total)
Automatically broadcast a message through the facility at specific times
* Welcome message
* Chaos announcement
* Change ntf announcement
* Round start
* Timed/Delayed
* Intervals
* Spawn Broadcasts

# Support
* For any issues create an issue or contact me on [Discord](https://discord.gg/RYzahv3vfC).
* Also use the Discord for suggestions :)

# Default Config
```yaml
AutoBroadcast:
is_enabled: true
debug: false
join_message:
# How long the hint/broadcast should show
duration: 4
# The message shown on the broadcast
message: 'Welcome, %name%!'
# Override broadcasts
override_broadcasts: false
chaos_announcement:
# The CASSIE message to be sent
message: 'Warning . Military Personnel has entered the facility . Designated as, Chaos Insurgency.'
# The text to be shown
translation: 'Warning. Military Personnel has entered the facility. Designated as, Chaos Insurgency.'
# Whether or not to hide the subtitle for the cassie message
show_subtitles: false
cassie_round_start:
# The CASSIE message to be sent
message: 'Containment breach'
# The text to be shown
translation: 'Containment breach!'
# Whether or not to hide the subtitle for the cassie message
show_subtitles: false
broadcasts:
10:
# How long the hint/broadcast should show
duration: 5
# The message shown on the broadcast
message: '10 seconds have passed!'
# Override broadcasts
override_broadcasts: false
60:
# How long the hint/broadcast should show
duration: 6
# The message shown on the broadcast
message: '60 seconds have passed!'
# Override broadcasts
override_broadcasts: false
broadcast_intervals:
15:
# How long the hint/broadcast should show
duration: 3
# The message shown on the broadcast
message: 'Every 15 seconds!'
# Override broadcasts
override_broadcasts: false
120:
# How long the hint/broadcast should show
duration: 4
# The message shown on the broadcast
message: 'Every 120 seconds!'
# Override broadcasts
override_broadcasts: false
spawn_broadcasts:
Spectator:
message: 'You died!'
duration: 4
override: false
use_hints: true
Overwatch:
message: 'Overwatch initiated.'
duration: 6
override: false
use_hints: true
```
# Empty config
```yaml
AutoBroadcast:
is_enabled: true
debug: false
join_message:
# How long the hint/broadcast should show
duration: 0
# The message shown on the broadcast
message: ''
# Override broadcasts
override_broadcasts: false
chaos_announcement:
# The CASSIE message to be sent
message: ""
# The text to be shown
translation: ""
# Whether or not to hide the subtitle for the cassie message
show_subtitles: false
cassie_round_start:
# The CASSIE message to be sent
message: ""
# The text to be shown
translation: ""
# Whether or not to hide the subtitle for the cassie message
show_subtitles: false
broadcasts: {}
broadcast_intervals: {}
spawn_broadcasts: {}
```
* Also use the Discord for suggestions

0 comments on commit 52d1a19

Please sign in to comment.