1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
local lastzone = nil
local drawspot = nil
local offset = {300,-300}
local drawtime = CurTime()
local function drawhint(ply,text)
if not IsValid(LocalPlayer()) then return end
drawtime = CurTime()
local lpep = LocalPlayer():EyePos()
local lpea = EyeAngles()
lpea.p = 0
local ep = lpep + (lpea:Forward() * offset[1]) + (lpea:Right()*offset[2])
local tr = util.TraceLine( {
start = lpep,
endpos = ep,
filter = LocalPlayer()
})
local tr2 = {}
if not tr.Hit then
tr2 = util.TraceLine({
start = ep,
endpos = lpep + (lpea:Forward() * offset[1] * 2)
})
end
if tr.Hit then
print("tr1 hit")
local pos = tr.HitPos
local norm = tr.HitNormal
drawspot = {pos,norm,text}
elseif tr2.Hit then
print("tr2 hit")
drawspot = {tr2.HitPos,tr2.HitNormal,text}
else
print("neigher 1 nor 2 hit")
local pos = lpep + (lpea:Forward() * offset[1]) + (lpea:Right()*offset[2])
local norm = lpep - pos
drawspot = {pos,norm,text}
end
end
drawhint(LocalPlayer(),"test")
hook.Add("PreDrawEffects","draw_test",function()
if not drawspot then return end
--drawhint(LocalPlayer(),"test")
local lpea1 = drawspot[2]:Angle()
--render.DrawLine(drawspot[1],drawspot[1] + (lpea1),Color(255,0,0),false)
--render.DrawLine(drawspot[1],drawspot[1]+Vector(0,0,10),Color(0,255,0),false)
local lpea = EyeAngles()
lpea.p = 0
local zoff = 0
local delta = CurTime() - drawtime
if delta < 0.5 then
zoff = -100 + (100 * (delta/0.5))
elseif delta < 3 then
zoff = 0
elseif delta < 3.5 then
zoff = 100 * -((delta-3)/0.5)
else
return
end
cam.Start3D2D( drawspot[1] + Vector(0,0,zoff), lpea1 + Angle(0,90,90), 1 )
surface.SetFont( "Trebuchet24" )
surface.SetTextColor( 255, 255, 255, 255 )
surface.SetTextPos( 0, 0 )
surface.DrawText( drawspot[3] )
cam.End3D2D()
end)
hook.Add("Tick","player_zone_alerts",function()
if not IsValid(LocalPlayer()) then return end
local tzone = LocalPlayer():GetCurrentZone()
if lastzone != tzone then
if lastzone == nil and tzone.Name then
drawhint(LocalPlayer(),"Entering: " .. tzone.Name)
elseif lastzone and lastzone.Name then
drawhint(LocalPlayer(),"Leaving: " .. lastzone.Name)
end
lastzone = tzone
end
end)
|