CapsAdmin

Untitled

Dec 4th, 2011
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.92 KB | None | 0 0
  1. if SERVER then
  2.     hook.Add("PPhys",1,function(ply, ent, phys)
  3.         if phys:IsValid() then
  4.             phys:EnableGravity(false)
  5.  
  6.             ply.mousex = ply.mousex or 0
  7.             ply.mousey = ply.mousey or 0
  8.  
  9.             if not ent.thrust_sound then
  10.                 ent.thrust_sound = CreateSound(ent, "ambient/gas/cannister_loop.wav")
  11.                 ent.thrust_sound:Play()
  12.             end
  13.  
  14.             local dir = Vector(0,0,0)
  15.             local eye = ent:GetAngles()
  16.             local aim = eye:Forward()
  17.             local side = eye:Right()
  18.             local mult = 6
  19.  
  20.             local vol = 0
  21.  
  22.             if ply.mousex ~= 0 or ply.mousey ~= 0 then
  23.                 vol = 1
  24.             end
  25.  
  26.             if ply:KeyDown(IN_SPEED) then
  27.                 mult = mult * 2
  28.             end
  29.  
  30.             if ply:KeyDown(IN_FORWARD) then
  31.                 phys:AddVelocity(aim * mult)
  32.                 vol = 1
  33.             end
  34.  
  35.             if ply:KeyDown(IN_JUMP) then
  36.                 phys:AddVelocity(eye:Up() * mult)
  37.                 vol = 1
  38.             end
  39.  
  40.             if ply.crouching then
  41.                 phys:AddVelocity(eye:Up() * -mult)
  42.                 vol = 1
  43.             end
  44.  
  45.             if ply:KeyDown(IN_BACK) then
  46.                 phys:AddVelocity(aim * -mult)
  47.                 vol = 1
  48.             end
  49.  
  50.             if ply:KeyDown(IN_MOVELEFT) then
  51.                 if ply:KeyDown(IN_WALK) then
  52.                     phys:AddAngleVelocity(Angle(-mult*0.3, 0, 0))
  53.                 else
  54.                     phys:AddVelocity(side * -mult)
  55.                 end
  56.                 vol = 1
  57.             end
  58.  
  59.             if ply:KeyDown(IN_MOVERIGHT) then
  60.                 if ply:KeyDown(IN_WALK) then
  61.                     phys:AddAngleVelocity(Angle(mult*0.3, 0, 0))
  62.                 else
  63.                     phys:AddVelocity(side * mult)
  64.                 end
  65.                 vol = 1
  66.             end
  67.  
  68.             ent.thrust_sound:ChangeVolume(vol)
  69.             ent.thrust_sound:ChangePitch(200)
  70.  
  71.             phys:AddAngleVelocity(Angle(0, ply.mousey*0.05, -ply.mousex*0.05))
  72.  
  73.             phys:AddVelocity(-phys:GetVelocity()*0.01)
  74.             phys:AddAngleVelocity(-phys:GetAngleVelocity()*0.01)
  75.  
  76.             --ply:SetDSP(14)
  77.         end
  78.     end)
  79.  
  80.     hook.Add("Move",1,function(ply)
  81.         if ply:HasPlayerPhysics() then
  82.             local cmd = ply:GetCurrentCommand()
  83.  
  84.             ply.mousex = cmd:GetMouseX()
  85.             ply.mousey = cmd:GetMouseY()
  86.         end
  87.     end)
  88.  
  89.     concommand.Add("+thrust_crouch", function(ply, _, args)
  90.         ply.crouching = true
  91.     end)
  92.  
  93.     concommand.Add("-thrust_crouch", function(ply, _, args)
  94.         ply.crouching = false
  95.     end)
  96. end
  97.  
  98. if CLIENT then
  99.     hook.Add("SetPlayerPhysics", 1, function(ply, ent)
  100.         ply.pphys_request_duck = true
  101.     end)
  102.  
  103.     hook.Add("CreateMove", 1, function(ucmd)
  104.         local ply = LocalPlayer()
  105.         if ply:HasPlayerPhysics() then
  106.             ucmd:SetViewAngles(Angle(0,0,0))
  107.  
  108.             if ply.pphys_request_duck then
  109.                 RunConsoleCommand("+duck")
  110.             end
  111.         end
  112.     end)
  113.  
  114.     hook.Add("PlayerBindPress", 1,function(ply, bind, pressed)
  115.         if not  bind:find("duck") then return end
  116.         if ply.pphys_request_duck then
  117.             ply.pphys_request_duck = nil
  118.             RunConsoleCommand("-duck")
  119.         return end
  120.  
  121.         if ply:HasPlayerPhysics() then
  122.  
  123.             if pressed then
  124.                 RunConsoleCommand("+thrust_crouch")
  125.             else
  126.                 RunConsoleCommand("-thrust_crouch")
  127.             end
  128.  
  129.             print(pressed)
  130.  
  131.             return true
  132.         end
  133.     end)
  134. end
  135.  
  136. if false and SERVER then
  137.     all:SetPlayerPhysics(false)
  138.     timer.Simple(0.2, function()
  139.         all:SetPlayerPhysics(true)
  140.     end)
  141. end
  142.  
Advertisement
Add Comment
Please, Sign In to add comment