Chat/ Typing Indicator

So I’ve managed to search the forums and find a working chat indicator, although its not exactly what i expected it to be.
I’ve got very little knowledge of Lua. Hopefully someone can edit this code and help me understand it.

Basically I just want the model that spawns above someones head to rotate.

Here’s the code; I think it’s kind of outdated. Also it displays a message in console
every time someone says something or stops chatting. it is just plain annoying to
see that message popping up everytime someone attempts to chat.

if CLIENT then
ErrorNoHalt(“Adding Chatclicker Hooks…”)
hook.Add(“StartChat”, “chatclicker.start”, function() RunConsoleCommand(“chatclicker.start”) end)
hook.Add(“FinishChat”, “chatclicker.end”, function() RunConsoleCommand(“chatclicker.end”) end)
ErrorNoHalt("Done!
")
end

if not SERVER then return end
AddCSLuaFile(“autorun/chatclicker.lua”)

concommand.Add(“chatclicker.start”, function(ply, cmd, n)
if not ply:IsValid() then return end
if ply.chatprop != nil and ply.chatprop:IsValid() then ply.chatprop:Remove() end
ply.chatprop = ents.Create(“prop_physics”)
ply.chatprop:SetModel(“models/extras/info_speech.mdl”)
ply.chatprop:SetPos(ply:LocalToWorld(Vector(0, 0, 100)))
ply.chatprop:SetAngles(ply:GetAngles())
ply.chatprop:SetParent(ply)
end)
concommand.Add(“chatclicker.end”, function(ply, cmd, n)
if not ply:IsValid() then return end
if ply.chatprop:IsValid() then ply.chatprop:Remove() end
end)

Thanks - Ratt

Please use [lua] tags around your code, it makes it easier to read.

Here you are:

[lua]
if CLIENT then
ErrorNoHalt(“Adding Chatclicker Hooks…”)
hook.Add(“StartChat”, “chatclicker.start”, function() RunConsoleCommand(“chatclicker.start”) end)
hook.Add(“FinishChat”, “chatclicker.end”, function() RunConsoleCommand(“chatclicker.end”) end)
ErrorNoHalt("Done!
")
end

if not SERVER then return end
AddCSLuaFile(“autorun/chatclicker.lua”)

concommand.Add(“chatclicker.start”, function(ply, cmd, n)
if not ply:IsValid() then return end
if ply.chatprop != nil and ply.chatprop:IsValid() then ply.chatprop:Remove() end
ply.chatprop = ents.Create(“prop_physics”)
ply.chatprop:SetModel(“models/extras/info_speech.mdl”)
ply.chatprop:SetPos(ply:LocalToWorld(Vector(0, 0, 100)))
ply.chatprop:SetAngles(ply:GetAngles())
ply.chatprop:SetParent(ply)
end)

concommand.Add(“chatclicker.end”, function(ply, cmd, n)
if not ply:IsValid() then return end
if ply.chatprop:IsValid() then ply.chatprop:Remove() end
end)

local rate = 1 – increase this number if it’s too slow, decrease if it’s too fast
hook.Add(“Think”, “RotateChatProp”, function()
for _, pl in ipairs( player.GetAll() ) do
if ValidEntity( pl.chatprop ) then
pl.chatprop:SetAngles( pl.chatprop:GetAngles() + Angle( 0, rate, 0 ) )
end
end
end)
[/lua]

You should lock the player so he can’t fraud it and run around with a prop on his head.

And if you don’t want any glitches I wouldn’t give it a physics property and do a trace to see if its a valid spot to place it.