Quick question, probably something stupid I'm missing.
I'm trying to create DarkRP weapons with existing FA: S models, but I'm having trouble with `SWEP:Reload()`
(NB: I've included pastes of all the files I mention at the end of the post)
For example, in `fas_2.0_alpha_sweps_180507408\lua\weapons\fas2_ak47\shared.lua`, there is this code:
SWEP.Anims = {}
SWEP.Anims.Reload = "reload"
Then, in `fas_2.0_alpha_sweps_180507408\lua\weapons\fas2_base`, `SWEP:Reload()` has the following code:
FAS2_PlayAnim(self, self.Anims.Reload)
self.Owner:SetAnimation(PLAYER_RELOAD)
Finally, in `fas_2.0_alpha_sweps_180507408\lua\autorun\fas2_shared.lua`, `FAS2_PlayAnim()` is defined as:
function FAS2_PlayAnim(wep, anim, speed, cyc, time)
speed = speed and speed or 1
cyc = cyc and cyc or 0
time = time or 0
-- snip
if wep.Sounds[anim] then
wep.CurSoundTable = wep.Sounds[anim]
wep.CurSoundEntry = 1
wep.SoundSpeed = speed
wep.SoundTime = CurTime() + time
end
-- snip
if CLIENT then
vm = wep.Wep
wep.CurAnim = string.lower(anim)
if vm then
vm:SetCycle(cyc)
vm:SetSequence(anim)
vm:SetPlaybackRate(speed)
end
end
end
My current code (in `addons\darkrpmodification\lua\weapons\weapon_ak47custom\shared.lua`) looks like this:
function SWEP:Reload()
-- local sequence = self:LookupSequence( "reload" )
if CLIENT then
self.CurAnim = "reload"
self.Weapon:SetCycle( 0 )
self.Weapon:SetSequence( self.Anims.Reload )
self.Weapon:SetPlaybackRate( 1 )
end
self.Owner:SetAnimation(PLAYER_RELOAD)
end
However, when I hit my reload key in-game, nothing happens. No Lua errors, the ammo doesn't refill, nothing. Is there something stupid simple I'm missing? Thanks in advance for the help.
Files:
[Lua] weapon_ak47customshared.lua (line 67)
[Lua] fas2_ak47shared.lua (line 34)
[Lua] fas2_baseshared.lua (line 342)
[Lua] autorunfas2_shared (line 1041)
Firstly, Entity/SetSequence only accepts numbers. Secondly, calling the function on the weapon will only effect the worldmodel. Lastly, you really should be using Weapon/SendWeaponAnim with ACT_VM_RELOAD - sequence names are inconsistent.
The code you provided is still calling SetSequence - check to make sure it exists on your model.
Sorry, you need to Log In to post a reply to this thread.