Guest User

Untitled

a guest
Jul 7th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. if CLIENT then
  2. function CustomPlayerBindPress(pl, bind, wasin)
  3. if bind == "+walk" then
  4. pl.Walk = wasin
  5. net.Start( "c2s_GoWalk" )
  6. net.WriteBit( pl.Walk )
  7. net.SendToServer()
  8. return true
  9. end
  10. end
  11. hook.Add("PlayerBindPress", "CustomPlayerBindPress", CustomPlayerBindPress)
  12. end
  13.  
  14. if SERVER then
  15. util.AddNetworkString( "c2s_GoWalk" );
  16. net.Receive( "c2s_GoWalk", function( len, ply )
  17.  
  18. ply.Walk = net.ReadBit()
  19. if ply.Walk == 1 then
  20. ply.Walk = true
  21. else
  22. ply.Walk = false
  23. end
  24.  
  25. if ply.Walk then
  26. if ply:GetSlot( "slot_offhand" ) and ply:GetSlot( "slot_primaryweapon" ) and ply:GetActiveWeapon().WeaponTable.HoldType == "pistol" then
  27. ply:SetLuaAnimation( "shield_idle" )
  28. end
  29. elseif !ply.Walk then
  30. if ply:GetSlot( "slot_offhand" ) and ply:GetSlot( "slot_primaryweapon" ) then
  31. ply:ResetLuaAnimation( "shield_lower" )
  32. ply:ResetLuaAnimation( "shield_idle", 1 )
  33. end
  34.  
  35. -- ply.IsSlowingDown = false
  36. -- ply:SlowDown( .001 )
  37. end
  38.  
  39. end)
  40. end
  41.  
  42. local Player = FindMetaTable("Player")
  43.  
  44. intDefaultPlayerSpeed = 210
  45. intDefaultSlowSpeed = 30
  46.  
  47. function Player:SetMoveSpeed(intAmount)
  48. self.MoveSpeed = intDefaultPlayerSpeed
  49. self.MoveSpeed = math.Clamp(intAmount or self.MoveSpeed, 0, 1000)
  50. self:SetWalkSpeed(math.Clamp(self.MoveSpeed, 0, 1000))
  51. self:SetRunSpeed(math.Clamp(self.MoveSpeed, 0, 1000))
  52. end
  53.  
  54. local mult = 0.1
  55. local function isWalk( player )
  56. if ((player.Walk) or ( player.SlowTime and player.SlowTime > CurTime() )) then
  57. return true
  58. else
  59. return false
  60. end
  61. end
  62.  
  63. function Player:SlowDown(intTime)
  64. self.SlowDownTimes = self.SlowDownTimes or {}
  65. self.SlowTime = CurTime() + intTime
  66. if SERVER then
  67. umsg.Start( "slowBdcst" )
  68. umsg.Entity( self )
  69. umsg.Float( intTime )
  70. umsg.End()
  71. end
  72. end
  73.  
  74.  
  75. if CLIENT then
  76. usermessage.Hook( "slowBdcst", function( um )
  77. local ply = um:ReadEntity()
  78. local int = um:ReadFloat()
  79. ply.SlowTime = CurTime() + int + .1
  80. end)
  81. end
  82.  
  83. hook.Add("PlayerSpawn", "PlayerSpawn_Movement", function(ply)
  84. ply:SetMoveSpeed()
  85. end)
  86.  
  87. hook.Add("Move", "Ironsightslowdownins", function(pl, move)
  88.  
  89. local fwd = move:GetForwardSpeed()
  90. local sid = move:GetSideSpeed()
  91. if fwd>0 then
  92. if isWalk( pl ) then
  93. local szx = -pl:GetMaxSpeed() * -mult
  94. if fwd>szx then
  95. move:SetForwardSpeed(szx)
  96. end
  97. end
  98. end
  99. if fwd<0 then
  100. if isWalk( pl ) then
  101. local szg = -pl:GetMaxSpeed() * mult
  102. if fwd<szg then
  103. move:SetForwardSpeed(szg)
  104. end
  105. end
  106. end
  107. if sid>0 then
  108. if isWalk( pl ) then
  109. local sidszg = -pl:GetMaxSpeed() * -mult
  110. if sid>sidszg then
  111. move:SetSideSpeed(sidszg)
  112. end
  113. end
  114. end
  115. if sid<0 then
  116. if isWalk( pl ) then
  117. local sidszgh = -pl:GetMaxSpeed() * mult
  118. if sid<sidszgh then
  119. move:SetSideSpeed(sidszgh)
  120. end
  121. end
  122. end
  123.  
  124. end)
Advertisement
Add Comment
Please, Sign In to add comment