Garry's Mod Wiki

Player:AnimRestartGesture

Player:AnimRestartGesture( number slot, number activity, boolean autokill = false )

Description

Restart a gesture on a player, within a gesture slot.

This is not automatically networked. This function has to be called on the client to be seen by said client.

Arguments

1 number slot
Gesture slot using Enums/GESTURE_SLOT
2 number activity
The activity ( see Enums/ACT ) or sequence that should be played
3 boolean autokill = false
Whether the animation should be automatically stopped. true = stops the animation, false = the animation keeps playing/looping

Example

Defines part of a SWEP with pistol whipping functionality by using a pistol hold type and AnimRestartGesture for the melee attack animation.

function SWEP:Initialize() self:SetHoldType("pistol") end function SWEP:PrimaryAttack() -- Weapon attack delay self:SetNextPrimaryFire(CurTime()+0.5) -- Get entity in front of us local tr = util.TraceLine(util.GetPlayerTrace(self.Owner)) local ent = tr.Entity -- If there's an enemy under 50 units in front of us if(IsValid(ent) && self.Owner:GetShootPos():Distance(tr.HitPos) < 50) then -- Play the melee attack animation self.Owner:AnimRestartGesture(GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_HL2MP_GESTURE_RANGE_ATTACK_MELEE, true) -- Create damage info (server-side) if SERVER then local dmg = DamageInfo() dmg:SetDamage(math.random(5, 10)) dmg:SetAttacker(self.Owner) dmg:SetInflictor(self) dmg:SetDamageForce(self.Owner:GetAimVector()*300) dmg:SetDamagePosition(tr.HitPos) dmg:SetDamageType(DMG_CLUB) -- Apply damage to enemy ent:TakeDamageInfo(dmg) end -- Play impact sound ent:EmitSound("physics/flesh/flesh_impact_bullet"..math.random(1, 5)..".wav") -- Make viewmodel pistol whip effect self.Owner:ViewPunch(Angle(0, 45, 0)) else -- Typical pistol shot code goes here -- Some can be found in 'weapon_base/shared.lua' end end

Page Links


Special Pages


Wikis

?

Render Time: 47ms

Session 0
DB GetPage 4
Generate Html 19
SaveChanges 8
Render Body 0
Render Sidebar 13