• ply:SetRunSpeed not changing run speed?
    4 replies, posted
if Energy < 20 then ply:SetRunSpeed( 0 ) end I need the player to be unable to run when his energy reaches 0
Don't set the run speed since it might conflict with other addons or the gamemode itself. Instead, remove the IN_SPEED key from the movedata in a shared GM/SetupMove hook.
trying , but this isnt working either. Thanks for your help so far local CMoveData = FindMetaTable( "CMoveData" ) function CMoveData:RemoveKeys( keys ) -- Using bitwise operations to clear the key bits. local newbuttons = bit.band( self:GetButtons(), bit.bnot( keys ) ) self:SetButtons( newbuttons ) end hook.Add( "SetupMove", "Disable Speeding", function( ply, mvd, cmd ) if mvd:KeyDown( IN_SPEED ) then mvd:RemoveKeys( IN_SPEED ) end
Try a StartCommand hook instead and perform the removal on the ucmd.
Almost got it! if Energy < 20 then hook.Add("StartCommand", "NoSprint", function(p,cmd) cmd:RemoveKey(IN_SPEED); end); This works but now to give the key back to the player when energy > 20
Sorry, you need to Log In to post a reply to this thread.