[QUOTE=Jackthemaster;21208786]I've made a little glock swep recently and I noticed that I need to put an animation when you run out of bullets. So I did this:
[lua]function SWEP:Think()
if self.Owner:GetActiveWeapon():Clip1() == 0 then
self.Weapon:SendWeaponAnim( ACT_VM_IDLE_EMPTY )
end
end
[/lua]
The gun fires and all, and there aren't any errors, but the animation won't show up. Why not?[/QUOTE]
It has to ATLEAST have the animation there.
Ah nevermind I fixed it.
I've made a little glock swep recently and I noticed that I need to put an animation when you run out of bullets. So I did this:
[lua]function SWEP:Think()
if self.Owner:GetActiveWeapon():Clip1() == 0 then
self.Weapon:SendWeaponAnim( ACT_VM_IDLE_EMPTY )
end
end
[/lua]
The gun fires and all, and there aren't any errors, but the animation won't show up. Why not?
[QUOTE=Jackthemaster;21208786]I've made a little glock swep recently and I noticed that I need to put an animation when you run out of bullets. So I did this:
[lua]function SWEP:Think()
if self.Owner:GetActiveWeapon():Clip1() == 0 then
self.Weapon:SendWeaponAnim( ACT_VM_IDLE_EMPTY )
end
end
[/lua]
The gun fires and all, and there aren't any errors, but the animation won't show up. Why not?[/QUOTE]
Ah yes. I think i know your problem.
The animation is playing. Look closely and you'll notice the gun twitching.
However, since this is run every Think, the animation is being played every Think while the ammo is zero.
So basically, you'll need a variable to show that the gun isn't already at zero, so it only plays the animation every time the ammo CHANGES to zero.
So for instance...
[lua]function SWEP:Think()
if self.Owner:GetActiveWeapon():Clip1() == 0 and ToEmpty then
self.Weapon:SendWeaponAnim( ACT_VM_IDLE_EMPTY )
ToEmpty = false
end
if self.Owner:GetActiveWeapon():Clip1() > 0 and not ToEmpty then
self.Weapon:SendWeaponAnim( ACT_VM_IDLE_EMPTY )
ToEmpty = true
end
end
[/lua]
Try that.
Sorry, you need to Log In to post a reply to this thread.