Gamemode.DoAnimationEvent

From GMod Wiki

Revision as of 14:21, 7 November 2010 by Cube334 (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Event Hook
Hook NameDoAnimationEvent
SyntaxGM:DoAnimationEvent( Player ply, Event event, Data data )
DescriptionAnimation
ReturnsNil
Lua StateNewerShared.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.DoAnimationEvent]Gamemode.DoAnimationEvent [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]

Examples

DescriptionI imagine this is called every second to set animation
Used onNewerShared.png
Code
 
function GM:DoAnimationEvent( ply, event, data )
    if event == PLAYERANIMEVENT_ATTACK_PRIMARY then
 
        if ply:Crouching() then
            ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_CROUCH_PRIMARYFIRE )
        else
            ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_STAND_PRIMARYFIRE )
        end
 
        return ACT_VM_PRIMARYATTACK
 
    elseif event == PLAYERANIMEVENT_ATTACK_SECONDARY then
 
        // there is no gesture, so just fire off the VM event
        return ACT_VM_SECONDARYATTACK
 
    elseif event == PLAYERANIMEVENT_RELOAD then
 
        if ply:Crouching() then
            ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_RELOAD_CROUCH )
        else
            ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_RELOAD_STAND )
        end
 
        return ACT_INVALID
 
    elseif event == PLAYERANIMEVENT_JUMP then
 
        ply.m_bJumping = true
        ply.m_bFirstJumpFrame = true
        ply.m_flJumpStartTime = CurTime()
 
        ply:AnimRestartMainSequence()
 
        return ACT_INVALID
 
    elseif event == PLAYERANIMEVENT_CANCEL_RELOAD then
 
        ply:AnimResetGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD )
 
        return ACT_INVALID
    end
 
    return nil
end
 
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox