Player cannot sprint sideways or backwards, only forwards.

I’m looking for a script that does what the title says - something making it unable for the player to sprint sideways and backwards, things that I gripe about constantly, making the player far more powerful at base than he needs to be in some situations.

So the player will walk sideways, and if he wants to go faster, he needs to hold his sprint key, which will make him jog (normal speed without sprint) in the direction he’s going. For my server this helps a lot with more realistic control on player flexibility.

Climb SWEP’s gradual acceleration already does it but that’s poor in custom-ability and makes the player run ridiculously fast.

You could just edit the Perfected Climb Swep’s maximum sprint speed or something like that. If they made it you run ridiculously fast you can make it adjustable to your likings, right?

Do you want it to be autorun on a server, or in togglable addon form?

Autorun on the server.

TheFacePuncher1, no, I can’t do that. If I edit the max speed it just screws everything up and makes you take forever to gain speed. I would prefer not having gradual acceleration, but the backwards/sideways movement quirks the Climb SWEP presented were nice.

I have something whipped up, not 100% sure on it though.

Just create a lua file in autorun\server and put the following code in:

[lua]function KeyPressed( ply )

if ply:KeyDown( IN_MOVELEFT ) or ply:KeyDown( IN_MOVERIGHT ) or ply:KeyDown( IN_BACK ) then
	ply:SprintDisable()
else
	ply:SprintEnable()
end

end
hook.Add(“KeyPress”, “KeyPressed”, KeyPressed)[/lua]

And you should be good to go, let me know of any errors.

I’ll test this right now, thanks guy.

[editline]08:30AM[/editline]

It didn’t work :frowning: Have any other ideas?

No Sorry :frowning:

No errors, just seems to not function.

I hope someone else can pick this up. Thanks for trying though, LuckyLuke, I appreciate it.

It was no problem, although i thought it would work :frowning:


function KeyPressed( ply )
	if (ply:IsValid()) then
		if ply:KeyDown (IN_SPEED) and ply:KeyDown( IN_MOVELEFT ) or ply:KeyDown( IN_MOVERIGHT ) or ply:KeyDown( IN_BACK ) then
			ply:SprintDisable()
		else
			ply:SprintEnable()
		end
	end
end
hook.Add("KeyPress", "KeyPressed", KeyPressed)

Try that

SprintDisable and SprintEnable are both broken. You should probably look into using the movement hooks in order to do this.

Yeah, that one wasn’t working either, and the same problem with it as the other one - no errors, just nothing was happening.

Thanks for the effort put into my request, however!


function KeyPressed( ply )
	if (ply:IsValid()) then
		if ply:KeyDown (IN_SPEED) and ply:KeyDown( IN_MOVELEFT ) or ply:KeyDown( IN_MOVERIGHT ) or ply:KeyDown( IN_BACK ) then
			ply:SetMoveType(MOVETYPE_STEP) -- NPC
		else
			ply:SetMoveType(MOVETYPE_WALK) -- Normal
		end
	end
end
hook.Add("KeyPress", "KeyPressed", KeyPressed)

I dont know if this would work; setting the players movetype as an NPC; they dont run too fast. Dont know if it makes a difference.

Done.

Yea, I was thinking about simply changing the RunSpeed, but I didnt think it was gonna work.

It works, even though it does give a little choppy movement when you do go in the affected directions. Thanks, mcormack!

That NPC movetype thing makes the player’s movement freeze up now and then, points for the effort and idea though.

No problem, if you need anything else done I might be interested.