Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if CLIENT then
- function CustomPlayerBindPress(pl, bind, wasin)
- if bind == "+walk" then
- pl.Walk = wasin
- net.Start( "c2s_GoWalk" )
- net.WriteBit( pl.Walk )
- net.SendToServer()
- return true
- end
- end
- hook.Add("PlayerBindPress", "CustomPlayerBindPress", CustomPlayerBindPress)
- end
- if SERVER then
- util.AddNetworkString( "c2s_GoWalk" );
- net.Receive( "c2s_GoWalk", function( len, ply )
- ply.Walk = net.ReadBit()
- if ply.Walk == 1 then
- ply.Walk = true
- else
- ply.Walk = false
- end
- if ply.Walk then
- if ply:GetSlot( "slot_offhand" ) and ply:GetSlot( "slot_primaryweapon" ) and ply:GetActiveWeapon().WeaponTable.HoldType == "pistol" then
- ply:SetLuaAnimation( "shield_idle" )
- end
- elseif !ply.Walk then
- if ply:GetSlot( "slot_offhand" ) and ply:GetSlot( "slot_primaryweapon" ) then
- ply:ResetLuaAnimation( "shield_lower" )
- ply:ResetLuaAnimation( "shield_idle", 1 )
- end
- -- ply.IsSlowingDown = false
- -- ply:SlowDown( .001 )
- end
- end)
- end
- local Player = FindMetaTable("Player")
- intDefaultPlayerSpeed = 210
- intDefaultSlowSpeed = 30
- function Player:SetMoveSpeed(intAmount)
- self.MoveSpeed = intDefaultPlayerSpeed
- self.MoveSpeed = math.Clamp(intAmount or self.MoveSpeed, 0, 1000)
- self:SetWalkSpeed(math.Clamp(self.MoveSpeed, 0, 1000))
- self:SetRunSpeed(math.Clamp(self.MoveSpeed, 0, 1000))
- end
- local mult = 0.1
- local function isWalk( player )
- if ((player.Walk) or ( player.SlowTime and player.SlowTime > CurTime() )) then
- return true
- else
- return false
- end
- end
- function Player:SlowDown(intTime)
- self.SlowDownTimes = self.SlowDownTimes or {}
- self.SlowTime = CurTime() + intTime
- if SERVER then
- umsg.Start( "slowBdcst" )
- umsg.Entity( self )
- umsg.Float( intTime )
- umsg.End()
- end
- end
- if CLIENT then
- usermessage.Hook( "slowBdcst", function( um )
- local ply = um:ReadEntity()
- local int = um:ReadFloat()
- ply.SlowTime = CurTime() + int + .1
- end)
- end
- hook.Add("PlayerSpawn", "PlayerSpawn_Movement", function(ply)
- ply:SetMoveSpeed()
- end)
- hook.Add("Move", "Ironsightslowdownins", function(pl, move)
- local fwd = move:GetForwardSpeed()
- local sid = move:GetSideSpeed()
- if fwd>0 then
- if isWalk( pl ) then
- local szx = -pl:GetMaxSpeed() * -mult
- if fwd>szx then
- move:SetForwardSpeed(szx)
- end
- end
- end
- if fwd<0 then
- if isWalk( pl ) then
- local szg = -pl:GetMaxSpeed() * mult
- if fwd<szg then
- move:SetForwardSpeed(szg)
- end
- end
- end
- if sid>0 then
- if isWalk( pl ) then
- local sidszg = -pl:GetMaxSpeed() * -mult
- if sid>sidszg then
- move:SetSideSpeed(sidszg)
- end
- end
- end
- if sid<0 then
- if isWalk( pl ) then
- local sidszgh = -pl:GetMaxSpeed() * mult
- if sid<sidszgh then
- move:SetSideSpeed(sidszgh)
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment