• Disabling Sprint
    14 replies, posted
I have a deathrun server and I was wondering how do I disable sprint? Code from gamemode/init.lua: [CODE]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[/CODE] Also you walk really slow after crouching or walking backwards... anyway to fix this?
[url]http://wiki.garrysmod.com/page/Player/SprintDisable[/url] (Doesn't work anymore but I'm not sure) [url]http://wiki.garrysmod.com/page/Player/SetRunSpeed[/url]
[QUOTE=MauriceG93;47333532][url]http://wiki.garrysmod.com/page/Player/SprintDisable[/url] (Doesn't work anymore but I'm not sure) [url]http://wiki.garrysmod.com/page/Player/SetRunSpeed[/url][/QUOTE] 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.
[QUOTE=MauriceG93;47333636]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.[/QUOTE] 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, [code] hook.Add("StartCommand", "NoSprint", function(p,cmd) cmd:RemoveKey(IN_SPEED); end); [/code] Run this code shared.
[QUOTE=MeepDarknessM;47334268]or, [code] hook.Add("StartCommand", "NoSprint", function(p,cmd) cmd:RemoveKey(IN_SPEED); end); [/code] Run this code shared.[/QUOTE] 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.
[QUOTE=F14;47335850]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.[/QUOTE] What gamemode base are you using? sandbox? base? custom?
[QUOTE=MeepDarknessM;47336337]What gamemode base are you using? sandbox? base? custom?[/QUOTE] Deathrun, it says it in the post.
[QUOTE=F14;47336367]Deathrun, it says it in the post.[/QUOTE] 1, there are many versions of deathrun 2, i asked what gamemode it uses for a base :v:
[QUOTE=MeepDarknessM;47336378]1, there are many versions of deathrun 2, i asked what gamemode it uses for a base :v:[/QUOTE] Yeah sorry, erm I use this one - [url]https://github.com/Mr-Gash/GMod-Deathrun[/url]
[url=https://github.com/Mr-Gash/GMod-Deathrun/blob/master/deathrun/gamemode/shared.lua#L78-L121]This hook[/url] is messing with velocity.
[QUOTE=MeepDarknessM;47336500][url=https://github.com/Mr-Gash/GMod-Deathrun/blob/master/deathrun/gamemode/shared.lua#L78-L121]This hook[/url] is messing with velocity.[/QUOTE] Oh ok, nice find man, so how do I fix this?
Sorry, you need to Log In to post a reply to this thread.