-
Notifications
You must be signed in to change notification settings - Fork 19
/
Freecam.lua
71 lines (57 loc) · 1.9 KB
/
Freecam.lua
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
--[[
Freecam for Lmaobox
Author: LNX (github.com/lnx00)
]]
local options = {
Key = KEY_LSHIFT,
Speed = 10
}
local vFreecamPos = Vector3(0, 0, 0)
local bFreecamActive = false
local function CreateMove(pCmd)
local pLocal = entities.GetLocalPlayer()
if input.IsButtonDown(options.Key) then
if not bFreecamActive then
vFreecamPos = pLocal:GetAbsOrigin()
bFreecamActive = true
end
local x, y, z = engine.GetViewAngles():Unpack()
local viewAngles = Vector3(x, y, z)
local vForward = viewAngles:Forward()
local vRight = viewAngles:Right()
local moveVector = Vector3(0, 0, 0)
if input.IsButtonDown(KEY_W) then
moveVector = moveVector + vForward
end
if input.IsButtonDown(KEY_S) then
moveVector = moveVector - vForward
end
if input.IsButtonDown(KEY_A) then
moveVector = moveVector - vRight
end
if input.IsButtonDown(KEY_D) then
moveVector = moveVector + vRight
end
moveVector:Normalize()
moveVector = moveVector * options.Speed
vFreecamPos = vFreecamPos + moveVector
pCmd:SetButtons(0)
pCmd:SetForwardMove(0)
pCmd:SetSideMove(0)
pCmd:SetUpMove(0)
else
bFreecamActive = false
end
end
local function PostPropUpdate()
if input.IsButtonDown(options.Key) and bFreecamActive then
local pLocal = entities.GetLocalPlayer()
pLocal:SetPropVector(vFreecamPos, "tfnonlocaldata", "m_vecOrigin")
--pLocal:SetAbsOrigin(vFreecamPos)
end
end
callbacks.Unregister("CreateMove", "CreateMove_Freecam")
callbacks.Unregister("PostPropUpdate", "FSN_Freecam")
callbacks.Register("CreateMove", "CreateMove_Freecam", CreateMove)
callbacks.Register("PostPropUpdate", "FSN_Freecam", PostPropUpdate)
client.Command('play "ui/buttonclick"', true)