Single question for SWEP LUA code

Greetings! so I basically got a weapon downloaded from Gamebanana, and I noticed that it has two reload animations, empty and non-empty magazine alike. As this gun was supposedly made for ‘Counter Strike: Source’, these animations get executed randomly. What I want is to configurate my LUA script so they can be displayed depending on empty or non-empty magazine when reloading. I already know some base like that from ‘Firearms: Source’ pack that contains the function, and I could probably track the specific code down by spending some time on searching through the script, but it’s still better if someone just told me directly as I feel a bit lazy. Cheers ;D

Just want to start off by welcoming you, and that it is Lua, not LUA.

As to when it’s empty and non-empty, check the players current Clip1, if it has ammo then play the one animation, if not then use the second.

Just look below to his code if you’re confused.

Hi there.

I’m currently doing the same thing for a project I am working on. Since i’m trying to get these to be as similar to Far Cry 3 as possible I had to make this code. Enjoy!

if ( self.Weapon:Clip1() <= 0 ) then – if there is no ammo in the weapon’s current mag
self.Weapon:DefaultReload(ACT_VM_RELOAD_EMPTY) – Play the empy animation
else – However if there is ammo in the weapon’s current mag
self.Weapon:DefaultReload(ACT_VM_RELOAD) – Then do the normal reload animation

Both reload types are named as ‘ACT_VM_RELOAD’ in qc file, as I decompiled the model for checking it. So I renamed one to ‘ACT_VM_RELOAD_EMPTY’ for making work the code which you shared. But sadly, the model gets completely corrupted when recompiling, so there’s no way I can do what I wanted. Thank you anyway, have a nice day.