2022-06-23 20:11:03 +10:00
|
|
|
using Content.Server.Chat.Systems;
|
2021-12-13 16:45:49 +11:00
|
|
|
using Content.Shared.Administration;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2020-12-03 03:40:47 +01:00
|
|
|
using Robust.Shared.Enums;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Chat.Commands
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
|
|
|
|
[AnyCommand]
|
2025-06-18 20:03:28 -04:00
|
|
|
internal sealed class SayCommand : LocalizedEntityCommands
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2025-06-18 20:03:28 -04:00
|
|
|
[Dependency] private readonly ChatSystem _chatSystem = default!;
|
|
|
|
|
public override string Command => "say";
|
2020-12-03 03:40:47 +01:00
|
|
|
|
2025-06-18 20:03:28 -04:00
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2023-10-28 09:59:53 +11:00
|
|
|
if (shell.Player is not { } player)
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2024-08-11 09:46:57 +00:00
|
|
|
shell.WriteError(Loc.GetString("shell-cannot-run-command-from-server"));
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-06 15:34:46 +01:00
|
|
|
if (player.Status != SessionStatus.InGame)
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
|
2021-12-06 15:34:46 +01:00
|
|
|
if (player.AttachedEntity is not {} playerEntity)
|
|
|
|
|
{
|
2025-06-18 20:03:28 -04:00
|
|
|
shell.WriteError(Loc.GetString($"shell-must-be-attached-to-entity"));
|
2021-12-06 15:34:46 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 03:40:47 +01:00
|
|
|
if (args.Length < 1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var message = string.Join(" ", args).Trim();
|
|
|
|
|
if (string.IsNullOrEmpty(message))
|
|
|
|
|
return;
|
|
|
|
|
|
2025-06-18 20:03:28 -04:00
|
|
|
_chatSystem.TrySendInGameICMessage(playerEntity, message, InGameICChatType.Speak, ChatTransmitRange.Normal, false, shell, player);
|
2020-12-03 03:40:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|