Add first join message (#13583)
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
using Content.Server.Database;
|
||||||
using Content.Server.Players;
|
using Content.Server.Players;
|
||||||
using Content.Shared.GameTicking;
|
using Content.Shared.GameTicking;
|
||||||
using Content.Shared.GameWindow;
|
using Content.Shared.GameWindow;
|
||||||
@@ -14,13 +15,14 @@ namespace Content.Server.GameTicking
|
|||||||
public sealed partial class GameTicker
|
public sealed partial class GameTicker
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
|
[Dependency] private readonly IServerDbManager _dbManager = default!;
|
||||||
|
|
||||||
private void InitializePlayer()
|
private void InitializePlayer()
|
||||||
{
|
{
|
||||||
_playerManager.PlayerStatusChanged += PlayerStatusChanged;
|
_playerManager.PlayerStatusChanged += PlayerStatusChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlayerStatusChanged(object? sender, SessionStatusEventArgs args)
|
private async void PlayerStatusChanged(object? sender, SessionStatusEventArgs args)
|
||||||
{
|
{
|
||||||
var session = args.Session;
|
var session = args.Session;
|
||||||
|
|
||||||
@@ -38,7 +40,13 @@ namespace Content.Server.GameTicking
|
|||||||
// timer time must be > tick length
|
// timer time must be > tick length
|
||||||
Timer.Spawn(0, args.Session.JoinGame);
|
Timer.Spawn(0, args.Session.JoinGame);
|
||||||
|
|
||||||
_chatManager.SendAdminAnnouncement(Loc.GetString("player-join-message", ("name", args.Session.Name)));
|
var record = await _dbManager.GetPlayerRecordByUserId(args.Session.UserId);
|
||||||
|
var firstConnection = record != null &&
|
||||||
|
Math.Abs((record.FirstSeenTime - record.LastSeenTime).TotalMinutes) < 1;
|
||||||
|
|
||||||
|
_chatManager.SendAdminAnnouncement(firstConnection
|
||||||
|
? Loc.GetString("player-first-join-message", ("name", args.Session.Name))
|
||||||
|
: Loc.GetString("player-join-message", ("name", args.Session.Name)));
|
||||||
|
|
||||||
if (LobbyEnabled && _roundStartCountdownHasNotStartedYetDueToNoPlayers)
|
if (LobbyEnabled && _roundStartCountdownHasNotStartedYetDueToNoPlayers)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,10 +26,11 @@ game-ticker-no-map-selected = [color=yellow]Map not yet selected![/color]
|
|||||||
game-ticker-player-no-jobs-available-when-joining = When attempting to join to the game, no jobs were available.
|
game-ticker-player-no-jobs-available-when-joining = When attempting to join to the game, no jobs were available.
|
||||||
|
|
||||||
# Displayed in chat to admins when a player joins
|
# Displayed in chat to admins when a player joins
|
||||||
player-join-message = Player {$name} joined the server!
|
player-join-message = Player {$name} joined.
|
||||||
|
player-first-join-message = Player {$name} joined for the first time.
|
||||||
|
|
||||||
# Displayed in chat to admins when a player leaves
|
# Displayed in chat to admins when a player leaves
|
||||||
player-leave-message = Player {$name} left the server!
|
player-leave-message = Player {$name} left.
|
||||||
|
|
||||||
latejoin-arrival-announcement = {$character} ({$job}) has arrived at the station!
|
latejoin-arrival-announcement = {$character} ({$job}) has arrived at the station!
|
||||||
latejoin-arrival-sender = Station
|
latejoin-arrival-sender = Station
|
||||||
|
|||||||
Reference in New Issue
Block a user