GM:SetupMove
This hook is predicted. This means that in singleplayer, it will not be called in the Client realm.
Description
SetupMove is called before the engine process movements. This allows us to override the players movement.
See Game Movement for an explanation on the move system.
Arguments
Example
Make drowning even more entertaining:
hook.Add( "SetupMove", "Drowning:HandleWaterInLungs", function( ply, mv, cmd )
if ( ply:WaterLevel() >= 2 ) then
mv:SetUpSpeed( -100 )
cmd:SetUpMove( -100 )
end
end )
Example
Disable the player's ability to jump by removing a key from CMoveData:
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 Jumping", function(ply, mvd, cmd)
if mvd:KeyDown(IN_JUMP) then
mvd:RemoveKeys(IN_JUMP)
end
end)