Gamemode.HandlePlayerJumping

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NameHandlePlayerJumping
SyntaxGM:HandlePlayerJumping( Player ply, Vector velocity )
DescriptionAnimation
ReturnsNil
Lua StateNewerShared.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.HandlePlayerJumping]Gamemode.HandlePlayerJumping [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]

Examples

DescriptionHandles animitions for jumping
Used onNewerShared.png
Code
 
 
function GM:HandlePlayerJumping( ply, velocity )
 
    // airwalk more like hl2mp, we airwalk until we have 0 velocity, then it's the jump animation
    // underwater we're alright we airwalking
    if !ply.m_bJumping && !ply:OnGround() && ply:WaterLevel() <= 0 then
 
        if !ply.m_fGroundTime then
            ply.m_fGroundTime = CurTime()
 
        elseif (CurTime() - ply.m_fGroundTime) > 0 && velocity:Length2D() < 0.5 then
            ply.m_bJumping = true
            ply.m_bFirstJumpFrame = false
            ply.m_flJumpStartTime = 0
        end
    end
 
    if ply.m_bJumping then
 
        if ply.m_bFirstJumpFrame then
            ply.m_bFirstJumpFrame = false
            ply:AnimRestartMainSequence()
        end
 
        if ( ply:WaterLevel() >= 2 ) ||
            ( (CurTime() - ply.m_flJumpStartTime) > 0.2 && ply:OnGround() ) then
            ply.m_bJumping = false
            ply.m_fGroundTime = nil
            ply:AnimRestartMainSequence()
        end
 
        if ply.m_bJumping then
            ply.CalcIdeal = ACT_MP_JUMP
            return true
        end
    end
 
    return false
end
 
OutputN/A

http://luabin.overvprojects.nl/?path=/gamemodes/base/gamemode/animations.lua

Additional Notes

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox