Disabling Sprint

I have a deathrun server and I was wondering how do I disable sprint?

Code from gamemode/init.lua:


function GM:PlayerSpawn( ply )

	ply._HasPressedKey = false

	if ply:Team() == TEAM_SPECTATOR then
		ply:Spectate(OBS_MODE_ROAMING)
		return
	end

	self.BaseClass:PlayerSpawn( ply )

	ply:SetHealth(ply:GetMaxHealth())
	ply:StripWeapons()
	ply:StripAmmo()
	ply:SetWalkSpeed(250)
	ply:SetRunSpeed(0)
	ply:AllowFlashlight(true)
	ply:SetArmor(0)
	
	ply:SetupHands()

	ply:SetJumpPower(190)

	local col = team.GetColor( ply:Team() )

	ply:SetPlayerColor( Vector( col.r/255, col.g/255, col.b/255 ) )

	local spawns = ents.FindByClass( ply:Team() == TEAM_RUNNER and "info_player_counterterrorist" or "info_player_terrorist" )

	if #spawns > 0 then
		local pos = table.Random( spawns ):GetPos()
		ply:SetPos( pos )

		timer.Simple( 1, function()
			if (IsValid(ply) and ply:Alive() and pos) then
				ply:SetPos( pos )
			end
		end )
	end

Also you walk really slow after crouching or walking backwards… anyway to fix this?

http://wiki.garrysmod.com/page/Player/SprintDisable (Doesn’t work anymore but I’m not sure)
http://wiki.garrysmod.com/page/Player/SetRunSpeed

Oh, I didn’t think so. Thanks for letting me know, do you know another way around it?

SetRunSpeed to the default player normal running speed.

I don’t know if it would work but you could try doing a client/server hook to block the sprint input.

I tried that before and it didn’t work, if you mean:
ply:SetWalkSpeed(250)
ply:SetRunSpeed(250)

Is there anything calling SetWalkSpeed/SetRunSpeed ?

Otherwise create a hook and block the sprint key, should be possible atleast, or create a move hook and limit the player running speed.

ply:SetWalkSpeed(250)
ply:SetRunSpeed(250)

Will work, make sure you aren’t calling it again in the gamemode as the latest one will overwrite what you put. I believe the Deathrun gamemode will set the walk/run speed itself somewhere, change that.

or,



hook.Add("StartCommand", "NoSprint", function(p,cmd)
    cmd:RemoveKey(IN_SPEED);
end);


Run this code shared.

This worked thanks! But still when I move sideways and backwards I slow down, its weird. Also how would I increase my walkspeed? Also crouch is very slow, bit like source when they patched bhoping.

What gamemode base are you using? sandbox? base? custom?

Deathrun, it says it in the post.

1, there are many versions of deathrun
2, i asked what gamemode it uses for a base :v:

Yeah sorry, erm I use this one -

This hook is messing with velocity.

Oh ok, nice find man, so how do I fix this?