Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function drawIndicator(ply, rag)
- local indicator = ply.indicator
- if not ply:IsTyping() then
- if isentity(indicator) and indicator:IsValid() then
- indicator:Remove()
- end
- return
- end
- if not isentity(indicator) or not indicator:IsValid() then
- indicator = ClientsideModel("models/extras/info_speech.mdl", RENDERGROUP_OPAQUE)
- if not indicator:IsValid() then return end
- ply.indicator = indicator
- indicator:SetNoDraw(true)
- indicator:SetModelScale(0.6)
- end
- local curTime = CurTime()
- local lastDraw = indicator.lastDraw
- if not isnumber(lastDraw) or lastDraw < 0 then
- lastDraw = 0
- end
- indicator.lastDraw = curTime
- local pos
- if rag == nil then
- indicator:SetParent(ply)
- pos = Vector(0, 0, ply:GetModelScale() * 72 + 12)
- else
- indicator:SetParent(rag)
- pos = rag:LocalToWorld(rag:EyePos())
- pos[3] = rag:GetModelScale() * 72 + 12
- end
- indicator:SetLocalPos(pos)
- local angle = indicator:GetAngles()
- angle[2] = (angle[2] + 360 * (curTime - lastDraw)) % 360
- indicator:SetAngles(angle)
- indicator:SetupBones()
- indicator:DrawModel()
- end
- hook.Add("PostPlayerDraw", "DarkRP_ChatIndicator", drawIndicator)
- local function indicatorOverride(rag)
- if rag:IsRagdoll() then
- local owner = rag:GetRagdollOwner()
- if owner:IsPlayer() then
- drawIndicator(owner, rag)
- end
- end
- rag:DrawModel()
- end
- hook.Add("CreateClientsideRagdoll", "DarkRP_ChatIndicator", function(ply, rag)
- if not ply:IsPlayer() then return end
- local oldRenderOverride = rag.RenderOverride
- if isfunction(oldRenderOverride) then
- -- This one cannot be stateless since the old render override must be called
- rag.RenderOverride = function(rag)
- if rag:IsRagdoll() then
- local owner = rag:GetRagdollOwner()
- if owner:IsPlayer() then
- drawIndicator(owner, rag)
- end
- end
- return oldRenderOverride(rag)
- end
- else
- rag.RenderOverride = indicatorOverride
- end
- end)
- -- CSEnts aren't GC'd.
- -- https://github.com/Facepunch/garrysmod-issues/issues/1387
- hook.Add("EntityRemoved", "DarkRP_ChatIndicator", function(ply)
- if not ply:IsPlayer() then return end
- local indicator = ply.indicator
- if isentity(indicator) and indicator:IsValid() then
- indicator:Remove()
- end
- end)
Add Comment
Please, Sign In to add comment