CapsAdmin

Untitled

Jul 7th, 2013
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- meta
  2. local Player = FindMetaTable("Player")
  3.  
  4. intDefaultPlayerSpeed = 210
  5. intDefaultSlowSpeed = 30
  6.  
  7. function Player:SlowDown(intTime)
  8. self.SlowDownTimes = self.SlowDownTimes or {}
  9. self.SlowTime = CurTime() + intTime
  10. end
  11.  
  12. function Player:SetMoveSpeed(intAmount)
  13. self.MoveSpeed = intDefaultPlayerSpeed
  14. self.MoveSpeed = math.Clamp(intAmount or self.MoveSpeed, 0, 1000)
  15. self:SetWalkSpeed(math.Clamp(self.MoveSpeed, 0, 1000))
  16. self:SetRunSpeed(math.Clamp(self.MoveSpeed, 0, 1000))
  17. end
  18.  
  19.  
  20. hook.Add("PlayerSpawn", "PlayerSpawn_Movement", function(ply)
  21. ply:SetMoveSpeed()
  22. end)
  23. end
  24.  
  25. -- animation
  26. do
  27. hook.Add("KeyPress", "walk", function(ply, key)
  28. if key == IN_WALK and ply:GetSlot( "slot_offhand" ) and ply:GetSlot( "slot_primaryweapon" ) and ply:GetActiveWeapon().WeaponTable.HoldType == "pistol" then
  29. ply:SetLuaAnimation( "shield_idle" )
  30. end
  31. end)
  32.  
  33. hook.Add("KeyRelease", "walk", function(ply, key)
  34. if key == IN_WALK and ply:GetSlot( "slot_offhand" ) and ply:GetSlot( "slot_primaryweapon" ) then
  35. ply:ResetLuaAnimation( "shield_lower" )
  36. ply:ResetLuaAnimation( "shield_idle", 1 )
  37. end
  38. end)
  39. end
  40.  
  41. do -- move hook
  42. local mult = 0.1
  43. local function isWalk( ply )
  44. if ply:KeyDown(IN_WALK) or ( ply.SlowTime and ply.SlowTime > CurTime() )) then
  45. return true
  46. else
  47. return false
  48. end
  49. end
  50.  
  51. hook.Add("Move", "PlayerSlowdown", function(ply, move)
  52.  
  53. local fwd = move:GetForwardSpeed()
  54. local sid = move:GetSideSpeed()
  55.  
  56. if isWalk( ply ) then
  57.  
  58. if fwd>0 then
  59. local szx = -ply:GetMaxSpeed() * -mult
  60.  
  61. if fwd>szx then
  62. move:SetForwardSpeed(szx)
  63. end
  64. end
  65.  
  66. if fwd<0 then
  67. local szg = -ply:GetMaxSpeed() * mult
  68.  
  69. if fwd<szg then
  70. move:SetForwardSpeed(szg)
  71. end
  72.  
  73. end
  74.  
  75. if sid>0 then
  76. local sidszg = -ply:GetMaxSpeed() * -mult
  77.  
  78. if sid>sidszg then
  79. move:SetSideSpeed(sidszg)
  80. end
  81. end
  82.  
  83. if sid<0 then
  84. local sidszgh = -ply:GetMaxSpeed() * mult
  85.  
  86. if sid<sidszgh then
  87. move:SetSideSpeed(sidszgh)
  88. end
  89. end
  90. end
  91.  
  92. end)
  93. end
Advertisement
Add Comment
Please, Sign In to add comment