fix "say" command

This commit is contained in:
in0finite 2022-04-23 02:44:10 +02:00
parent cc30f5ba54
commit 65c27e8d99
3 changed files with 14 additions and 3 deletions

View file

@ -57,7 +57,13 @@ namespace SanAndreasUnity.Chat
CommandManager.ProcessCommandResult ProcessSayCommand(CommandManager.ProcessCommandContext context)
{
ChatManager.SubmitChatMessage(CommandManager.GetRestOfTheCommand(context.command, 0));
string msg = CommandManager.GetRestOfTheCommand(context.command, 0);
if (context.player != null)
ChatManager.singleton.SubmitMessageFromPlayer(context.player, msg);
else
ChatManager.SendChatMessageToAllPlayersAsServer(msg);
return CommandManager.ProcessCommandResult.Success;
}
}

View file

@ -68,8 +68,13 @@ namespace SanAndreasUnity.Chat
Debug.Log(senderText + chatMessage.msg);
}
internal void OnChatMessageReceivedOnServer(Player player, string msg)
public void SubmitMessageFromPlayer(Player player, string msg)
{
NetStatus.ThrowIfNotOnServer();
if (null == player)
throw new System.ArgumentNullException(nameof(player));
msg = ChatManager.ProcessIncomingChatMessage(msg);
if (string.IsNullOrEmpty(msg))
return;

View file

@ -19,7 +19,7 @@ namespace SanAndreasUnity.Chat
[Command]
void CmdChatMsg( string msg )
{
F.RunExceptionSafe(() => ChatManager.singleton.OnChatMessageReceivedOnServer(m_player, msg));
F.RunExceptionSafe(() => ChatManager.singleton.SubmitMessageFromPlayer(m_player, msg));
}
internal void SendChatMsgToServer( string msg )