Skip to content

Commit

Permalink
Admin New Player Notification Sound (#200)
Browse files Browse the repository at this point in the history
# Description

Adds a quick ping sound that plays to every active (not de-adminned)
admin whenever a new player joins.
  • Loading branch information
DEATHB4DEFEAT authored Aug 31, 2023
1 parent d3dea41 commit a0c76bf
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Content.Server/Administration/Managers/AdminManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private async void LoginAdminMaybe(IPlayerSession session)

_admins.Add(session, reg);

if (!session.ContentData()!.ExplicitlyDeadminned)
if (session.ContentData() != null && !session.ContentData()!.ExplicitlyDeadminned) // Parkstation-NewPlayerPing: Server crashes if player is not in the database
{
reg.Data.Active = true;

Expand Down
10 changes: 10 additions & 0 deletions Content.Server/GameTicking/GameTicker.Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
using Content.Shared.GameTicking;
using Content.Shared.GameWindow;
using Content.Shared.Preferences;
using Content.Shared.SimpleStation14.CCVar;
using JetBrains.Annotations;
using Robust.Server.Player;
using Robust.Shared.Audio;
using Robust.Shared.Enums;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using PlayerData = Content.Server.Players.PlayerData;
Expand All @@ -19,6 +23,7 @@ public sealed partial class GameTicker
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly PlayTimeTrackingManager _playTimeTrackingManager = default!;
[Dependency] private readonly IServerDbManager _dbManager = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;

private void InitializePlayer()
{
Expand Down Expand Up @@ -68,6 +73,11 @@ private async void PlayerStatusChanged(object? sender, SessionStatusEventArgs ar
? Loc.GetString("player-first-join-message", ("name", args.Session.Name))
: Loc.GetString("player-join-message", ("name", args.Session.Name)));

if (firstConnection && _configurationManager.GetCVar(SimpleStationCCVars.AdminNewPlayerJoinSound))
_audioSystem.PlayGlobal(new SoundPathSpecifier("/Audio/Effects/newplayerping.ogg"),
Filter.Empty().AddPlayers(_adminManager.ActiveAdmins), false,
audioParams: new AudioParams { Volume = -5f });

if (LobbyEnabled && _roundStartCountdownHasNotStartedYetDueToNoPlayers)
{
_roundStartCountdownHasNotStartedYetDueToNoPlayers = false;
Expand Down
10 changes: 10 additions & 0 deletions Content.Shared/SimpleStation14/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ namespace Content.Shared.SimpleStation14.CCVar;
[CVarDefs]
public sealed class SimpleStationCCVars
{
#region Admin
public static readonly CVarDef<bool> AdminNewPlayerJoinSound =
CVarDef.Create("admin.new_player_join_sound", false, CVar.SERVERONLY);
#endregion

/*
* Announcers
*/
#region Announcers
/// <summary>
/// Optionally force set an announcer
/// </summary>
Expand All @@ -16,6 +25,7 @@ public sealed class SimpleStationCCVars
/// </summary>
public static readonly CVarDef<List<string>> AnnouncerBlacklist =
CVarDef.Create("game.announcer.blacklist", new List<string>(), CVar.SERVERONLY);
#endregion

/*
* End of round stats
Expand Down
Binary file added Resources/Audio/Effects/newplayerping.ogg
Binary file not shown.
3 changes: 3 additions & 0 deletions Resources/ConfigPresets/SimpleStation14/Parkstation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ patreon = "https://www.patreon.com/simple14"
[netres]
limit = 0.0

[admin]
new_player_join_sound = true


[build]
fork_id = "ParkStation14"

0 comments on commit a0c76bf

Please sign in to comment.