Garry's Mod Wiki

Garry's Mod Wiki

  number GM:DoAnimationEvent( Player ply, number event, number data = 0 )


Called upon an animation event, this is the ideal place to call player animation functions such as Player:AddVCDSequenceToGestureSlot, Player:AnimRestartGesture and so on.


1 Player ply
Player who is being animated
2 number event
Animation event. See PLAYERANIMEVENT enum
3 number data = 0
The data for the event. This is interpreted as an ACT enum by PLAYERANIMEVENT_CUSTOM and PLAYERANIMEVENT_CUSTOM_GESTURE, or a sequence by PLAYERANIMEVENT_CUSTOM_SEQUENCE.


1 number
The translated activity to send to the weapon. See ACT enum. Return ACT_INVALID if you don't want to send an activity.


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)

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated twice a day. Edits and history are not available.

Last Parsed: Loading...