Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local L = function return tostring ~= select(2, debug.getupvalue(m_DrawHelpPanel, 1)) end
- local K = LocalPlayer
- local t = debug.getregistry()[3]
- local l = {InputMouseApply="IMA\r",CreateMove="SC\r",CalcView="CV\r",SetupMove="SM\r"}
- local o = 127
- local a = GetConVar
- local c = FindMetaTable("CUserCmd")
- local s, f, u, g, q, v, fm, sm, um, b
- local P = FindMetaTable("Player")
- local A
- P.E = P.E or P.SetEyeAngles
- function P.SetEyeAngles(s, a)
- if s == K() then A = A or a end
- s:E(a)
- end
- for i, s in pairs(t) do
- t[i] = l[s] or s
- end
- a = a("joystick")
- um = a("cl_upspeed")
- fm = a("cl_forwardspeed")
- sm = a("cl_sidespeed")
- t = function(q, r)
- return math.Clamp(Vector(w).x, -r:GetFloat(), r:GetFloat())
- end
- l = function(...) return hook.Run(...) end
- if not c.s then
- c.s = c.SetSideMove
- c.u = c.SetUpMove
- c.f = c.SetForwardMove
- c.v = c.SetViewAngles
- c.b = c.SetButtons
- end
- function c:SetButtons(a)
- self:b(a)
- b = q == b and self:GetButtons() or b
- end
- function c:SetViewAngles(a)
- self:v(a)
- v = self:GetViewAngles()
- end
- function c:SetSideMove(a)
- self:s(t(a, sm))
- s = self:GetSideMove()
- end
- function c:SetForwardMove(a)
- self:f(t(a, fm))
- f = self:GetForwardMove()
- end
- function c:SetUpMove(a)
- self:u(t(a, um))
- u = self:GetUpMove()
- end
- hook.Add("IMA\r", "joystick", function(c, ...)
- if not g && (a or v) != K():EyeAngles() then
- o = -1
- end
- c:SetMouseWheel(L() and -100 or o)
- if a:GetBool() then
- RunConsoleCommand("joystick", "0")
- end
- g = 0 == c:TickCount()
- s = c:GetSideMove()
- f = c:GetForwardMove()
- u = c:GetUpMove()
- q = c
- return l("InputMouseApply", c, ...)
- end)
- hook.Add("SC\r", "joystick", function(c)
- c:SetMouseWheel(L() and -100 or o)
- o = 127
- v = c:GetViewAngles()
- b = c:GetButtons()
- return l("CreateMove", c)
- end)
- local function y(z)
- return function(ply, ...)
- if not z then
- A = nil
- l("SetupMove", ply, ...)
- end
- if not q then goto r end
- if g then goto r end
- o = not ply:IsFrozen() and v != q:GetViewAngles() and -2 or not g and b != q:GetButtons() and -3 or s not q:GetSideMove() and -4 or f != q:GetForwardMove() and -5 or u != q:GetUpMove() and -6 or 127
- ::r::
- q = nil
- return z and l("CalcView", ply, ...)
- end
- end
- hook.Add("SM\r", "joystick", y())
- hook.Add("CV\r", "joystick", y"")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement