GM:DoAnimationEvent
Description
Called upon an animation event, this is the ideal place to call player animation functions such as Player:AddVCDSequenceToGestureSlot, Player:AnimRestartGesture and so on.
Arguments
Returns
Example
Fires a custom animation event with PLAYERANIMEVENT_ATTACK_GRENADE
as the event, and 123 as the extra data on primary attack, and 321 as the secondary attack.
The player will play the item throw gesture on the primary attack, and the drop one on secondary.
function SWEP:PrimaryAttack()
self:GetOwner():DoCustomAnimEvent( PLAYERANIMEVENT_ATTACK_GRENADE , 123 )
self:SetNextPrimaryFire(CurTime() + 0.5 )
self:SetNextSecondaryFire(CurTime() + 0.5 )
end
function SWEP:SecondaryAttack()
self:GetOwner():DoCustomAnimEvent( PLAYERANIMEVENT_ATTACK_GRENADE , 321 )
self:SetNextPrimaryFire(CurTime() + 0.5 )
self:SetNextSecondaryFire(CurTime() + 0.5 )
end
hook.Add("DoAnimationEvent" , "AnimEventTest" , function( ply , event , data )
if event == PLAYERANIMEVENT_ATTACK_GRENADE then
if data == 123 then
ply:AnimRestartGesture( GESTURE_SLOT_GRENADE, ACT_GMOD_GESTURE_ITEM_THROW, true )
return ACT_INVALID
end
if data == 321 then
ply:AnimRestartGesture( GESTURE_SLOT_GRENADE, ACT_GMOD_GESTURE_ITEM_DROP, true )
return ACT_INVALID
end
end
end)