local stam = nil if SERVER then stam = nrequire("sv_stamina.lua") -- Depends on artery_stamina else stam = nrequire("cl_stamina.lua") end local dodgeing = {} local last_dodge = {} local tostop = {} hook.Add( "KeyPress", "keypress_dodge_toggle", function( ply, key ) if ( key == IN_WALK ) then dodgeing[ply] = true end end ) hook.Add( "KeyRelease", "keypress_dodge_toggle", function( ply, key ) if ( key == IN_WALK ) then dodgeing[ply] = false end end ) hook.Add( "PlayerInitialSpawn", "dodge_cooldown_init",function(ply) last_dodge[ply] = CurTime() end ) hook.Add( "PlayerDisconnected", "dodge_cooldown_desc",function(ply) last_dodge[ply] = nil end ) hook.Add( "Move", "move_dodge_dodge", function(ply,cmv) --print("Player's stamina was",stam.getStamina(ply)) if dodgeing[ply] and CurTime() > ((last_dodge[ply] or 0) + 1) and stam.getStamina(ply) >= 10 then if SERVER then stam.takeStamina(ply,10) end local vel = cmv:GetVelocity() vel.z = 0 vel = (vel * 20) + Vector(0,0,-64) for k,v in pairs({"x","y","z"}) do vel[v] = math.Clamp(vel[v],-1000,1000) end cmv:SetVelocity(vel) last_dodge[ply] = CurTime() tostop[ply] = CurTime() + 0.1 elseif tostop[ply] and CurTime() > tostop[ply] then cmv:SetVelocity(Vector(0,0,0)) tostop[ply] = nil end end)