jumping

Im trying to add a cool down to this


	if  pl:KeyDown( IN_USE ) and pl:KeyPressed( IN_JUMP ) and pl:OnGround() and not pl:GetNWBool( "zjump" ) and pl.ZeroGJump and pl:Team()==TEAM_HUMAN then
        pl:SetVelocity( Vector(0,0,355) )
		pl:SetNWBool( "zjump", true )
    end
end

function GM:OnPlayerHitGround( ply )
	ply:SetNWBool( "zjump", false )
end

I tried this whole CurTime thing, but it didn’t work. Could I get some help?

-bump-

You’re over-complicating this.

OnPlayerHitGround, set a time; the CurTime( ) that they hit the ground. On Server, Disable the jump key until a certain time has been met over the timer. So CurTime( ) - JumpTime < 3 then deny.

That’s what I’m also getting at, how should I disable use, or jump?

It may be easier just to set the jump-power of the player to 0 for that time period instead of detecting to see if jump was pressed on SetupMove, then remove it so they can’t jump…

You can do it by creating a timer; I’d recommend creating a standard timer with a name consisting of the Player:UniqueID( ) … “disable_jump” – so before the timer is called, set jump power to 0, in the timer which should only run 1 time after x seconds set it back to normal… The reason I say do that instead of a simple timer is so that it doesn’t glitch out if they walk off a ledge ( hitground will be called again )

so a little something like this?


function GM:OnPlayerHitGround( ply )
	ply:SetNWBool( "zjump", false )
	ply:SetVelocity( Vector(0,0,0) )
	timer.Create( "disable_jump", 3, 1, function() if pl:KeyDown( IN_USE ) and pl:KeyPressed( IN_JUMP ) and pl:OnGround() and not pl:GetNWBool( "zjump" ) and pl.ZeroGJump and pl:Team()==TEAM_HUMAN then
        pl:SetVelocity( Vector(0,0,355) )
		pl:SetNWBool( "zjump", true )
		end )
	end
end

No, a timer is only run once so you can’t do those checks in it. Additionally, when a second player jumps, you’ve just now made it so the first person will never recover their jump power.

I was thinking something more along the lines of this when I said::** “It may be easier just to set the jump-power of the player to 0 for that time period instead of detecting to see if jump was pressed on SetupMove, then remove it so they can’t jump…**”

And read this: You can do it by creating a timer; I’d recommend creating a standard timer with a name consisting of the Player:UniqueID( ) … “disable_jump” – so before the timer is called, set jump power to 0, in the timer which should only run 1 time after x seconds set it back to normal… The reason I say do that instead of a simple timer is so that it doesn’t glitch out if they walk off a ledge ( hitground will be called again )

[lua]local DEFAULT_JUMP_POWER = 160;
hook.Add( “OnPlayerHitGround”, “DisableJump:OnPlayerHitGround”, function( _p, bInWater, bOnFloater, flFallSpeed )
p:SetJumpPower( 0 );
timer.Create( "DisableJump
" … _p:UniqueID( ), 3, 1, function( )
_p:SetJumpPower( DEFAULT_JUMP_POWER );
end );
end );[/lua]

lol. Alright, well thanks for trying to help me. I should probably change it form vectors to jump power then.