diff --git a/emojichat/lua/autorun/emoji-chat.lua b/emojichat/lua/autorun/emoji-chat.lua index c12f45b..0729baa 100644 --- a/emojichat/lua/autorun/emoji-chat.lua +++ b/emojichat/lua/autorun/emoji-chat.lua @@ -14,7 +14,10 @@ if SERVER then AddCSLuaFile("emojichat/cl_text-component.lua") AddCSLuaFile("emojichat/cl_util.lua") + AddCSLuaFile("emojichat/sh_chat-overrides.lua") + include("emojichat/sv_chat.lua") + include("emojichat/sh_chat-overrides.lua") elseif CLIENT then include("emojichat/cl_echat.lua") @@ -25,4 +28,6 @@ elseif CLIENT then include("emojichat/cl_chat-overrides.lua") include("emojichat/cl_hooks.lua") include("emojichat/cl_html-chat-callbacks.lua") + + include("emojichat/sh_chat-overrides.lua") end \ No newline at end of file diff --git a/emojichat/lua/emojichat/cl_chat-overrides.lua b/emojichat/lua/emojichat/cl_chat-overrides.lua index 6978d36..3bd829b 100644 --- a/emojichat/lua/emojichat/cl_chat-overrides.lua +++ b/emojichat/lua/emojichat/cl_chat-overrides.lua @@ -1,4 +1,5 @@ local oldAddText = chat.AddText + function chat.AddText(...) eChat.AddLine(TextComponentBuilder.Build(...)) oldAddText(...) @@ -7,4 +8,4 @@ end chat.Open = eChat.showBox chat.Close = eChat.hideBox chat.GetChatBoxPos = function() return eChat.frame:GetPos() end -chat.GetChatBoxSize = function() return eChat.frame:GetSize() end +chat.GetChatBoxSize = function() return eChat.frame:GetSize() end \ No newline at end of file diff --git a/emojichat/lua/emojichat/cl_init.lua b/emojichat/lua/emojichat/cl_init.lua index 6cb17ab..d64179a 100644 --- a/emojichat/lua/emojichat/cl_init.lua +++ b/emojichat/lua/emojichat/cl_init.lua @@ -75,6 +75,7 @@ function eChat.hideBox() end eChat.HTMLOutput:SetInactive() + eChat.StopTyping() local children = eChat.frame:GetChildren() for _, pnl in pairs( children ) do @@ -103,6 +104,7 @@ function eChat.showBox(mode) end eChat.HTMLOutput:SetActive(mode) + eChat.StartTyping() local children = eChat.frame:GetChildren() for _, pnl in pairs( children ) do @@ -115,7 +117,7 @@ function eChat.showBox(mode) eChat.chatLog:RequestFocus() eChat.Active = true - hook.Run("StartChat") + hook.Run("StartChat", eChat.ChatMode == CHATMODE_TEAM) end function eChat.AddLine(textComponents) @@ -137,3 +139,15 @@ function eChat.UpdateFadeTime(durationInSeconds) eChat.HTMLOutput:UpdateFadeTime(eChat.config.fadeTime) end + +function eChat.StartTyping() + net.Start("SetTypingStatus") + net.WriteBool(true) + net.SendToServer() +end + +function eChat.StopTyping() + net.Start("SetTypingStatus") + net.WriteBool(false) + net.SendToServer() +end diff --git a/emojichat/lua/emojichat/sh_chat-overrides.lua b/emojichat/lua/emojichat/sh_chat-overrides.lua new file mode 100644 index 0000000..0704772 --- /dev/null +++ b/emojichat/lua/emojichat/sh_chat-overrides.lua @@ -0,0 +1,5 @@ +local meta = FindMetaTable( "Player" ) + +function meta:IsTyping() + return self:GetNWBool("IsTyping") +end diff --git a/emojichat/lua/emojichat/sv_chat.lua b/emojichat/lua/emojichat/sv_chat.lua index 6575ac9..278dc88 100644 --- a/emojichat/lua/emojichat/sv_chat.lua +++ b/emojichat/lua/emojichat/sv_chat.lua @@ -8,8 +8,14 @@ hook.Add("PlayerInitialSpawn", "echat_playerinitialspawn", function(ply) ply:ChatPrint(ply:Nick() .. " has joined the server.") end) - hook.Remove("PlayerDisconnected", "echat_playerdisconnected") hook.Add("PlayerDisconnected", "echat_playerdisconnected", function(ply) PrintMessage(HUD_PRINTTALK, ply:Nick() .. " has left the server.") end) + + +util.AddNetworkString("SetTypingStatus") +net.Receive("SetTypingStatus", function(len, ply) + local isTyping = net.ReadBool() + ply:SetNWBool("IsTyping", isTyping) +end)