1
+ if SERVER then
2
+ resource .AddSingleFile (" resource/fonts/RS-Bold-12.ttf" )
3
+ return
4
+ end
5
+
6
+ local tag = " RSChat"
7
+ local bEnabled = CreateConVar (" rschat_enabled" , " 1" , {FCVAR_ARCHIVE }, " Enables RuneScape style overhead chat." )
8
+ local iTTL = CreateConVar (" rschat_ttl" , " 3" , {FCVAR_ARCHIVE }, " Sets the amount of time the overhead chat message is displayed for in seconds." , 1 )
9
+ local fPadding = CreateConVar (" rschat_padding" , " 19" , {FCVAR_ARCHIVE }, " Sets the distance between the text and the players head." )
10
+ local fSize = CreateConVar (" rschat_size" , " 1" , {FCVAR_ARCHIVE }, " Sets the size of the overhead chat messages." )
11
+ local cChat , cChatShadow = Color (255 , 255 , 0 ), Color (25 , 25 , 0 )
12
+
13
+ surface .CreateFont (tag , {
14
+ font = " RuneScape Bold 12" ,
15
+ size = 130 ,
16
+ weight = 12 ,
17
+ extended = true ,
18
+ })
19
+
20
+ hook .Add (" OnPlayerChat" , tag , function (ply , text , isTeam )
21
+ print (ply , text , isTeam )
22
+ if not IsValid (ply ) then return end
23
+ if isTeam then return end
24
+
25
+ ply .RSChat = text
26
+ timer .Create (" RSChatTTL_" .. ply :EntIndex (), iTTL :GetInt (), 1 , function ()
27
+ ply .RSChat = nil
28
+ end )
29
+ end )
30
+
31
+ hook .Add (" PostDrawTranslucentRenderables" , tag , function ()
32
+ if not bEnabled :GetBool () then return end
33
+
34
+ for _ , ply in ipairs (player .GetAll ()) do
35
+ if not ply .RSChat then continue end
36
+ if ply :IsDormant () then continue end -- Only draw for players in PVS
37
+ if ply == LocalPlayer () and not ply :ShouldDrawLocalPlayer () then continue end -- Don't draw on yourself if you can't see yourself
38
+
39
+ local ePlayer = ply :GetRagdollEntity () == NULL and ply or ply :GetRagdollEntity ()
40
+ local iHead = ePlayer :LookupBone (" ValveBiped.Bip01_Head1" )
41
+ if not iHead then continue end -- If theres not a head, bail
42
+
43
+ local vHead = ePlayer :GetBonePosition (iHead )
44
+ if vHead == ePlayer :GetPos () then
45
+ vHead = ePlayer :GetBoneMatrix (iHead )
46
+ end
47
+
48
+ local fScale = ply :GetModelScale () -- take size into account
49
+ local vHeadUp = ePlayer :GetUp ()
50
+ local vPos = vHead + vHeadUp * fPadding :GetFloat () * fScale
51
+ local ang = EyeAngles ()
52
+
53
+ -- necessary evil?
54
+ ang :RotateAroundAxis (ang :Up (), - 90 )
55
+ ang :RotateAroundAxis (ang :Forward (), 90 )
56
+
57
+ -- rschat
58
+ cam .Start3D2D (vPos , ang , 0.035 * fScale * fSize :GetFloat ())
59
+ draw .SimpleText (ply .RSChat , tag , 6 , 6 , cChatShadow , TEXT_ALIGN_CENTER , TEXT_ALIGN_BOTTOM )
60
+ draw .SimpleText (ply .RSChat , tag , 0 , 0 , cChat , TEXT_ALIGN_CENTER , TEXT_ALIGN_BOTTOM )
61
+ cam .End3D2D ()
62
+ end
63
+ end )
0 commit comments