Can't run SWEP VM reload anim twice?

Update: I forgot I made this thread.

I still don’t know why it only happens in srcds.


Edit: Title is a lie, should be “SendWeaponAnim randomly fails on dedicated servers”
Observe the following code:

[lua]SWEP.PrintName = “reload anim lol”
SWEP.Spawnable = true
SWEP.ViewModel = “models/weapons/v_smg1.mdl”
SWEP.WorldModel = “models/weapons/w_smg1.mdl”

function SWEP:Reload()
if self.Reloading then return end
self.Reloading = true

if CLIENT then chat.AddText("reloading") end

self:EmitSound("Weapon_SMG1.Reload")

self:SendWeaponAnim(ACT_VM_RELOAD)
self.Owner:SetAnimation(PLAYER_RELOAD)

timer.Simple(self:SequenceDuration(), function()
	if self:IsValid() then
		if CLIENT then chat.AddText("done (" .. math.Round(CurTime(), 0) .. ")") end
		self.Reloading = false
	end
end)

end
[/lua]

In singleplayer or on a listen server, this works fine. Flawlessly. I can reload forever with no problems or animation glitches.

On a dedicated server on my own machine, when I reload the weapon one of three things will occasionally but not always happen:

  1. swep:EmitSound() has no effect
  2. swep:SendWeaponAnim() has no effect
  3. swep:SendWeaponAnim() causes the viewmodel to “twitch”, where it starts the reload animation and immediately stops

Video: Did my best to record it but the code above glitches very rarely compared to the SWEP I was working on originally. Like, 20-30 reloads work fine and then the next 3 fuck up kind of rare, and “the twitch” only seemed to show up when I wasn’t recording.

As you can see from the chat spam, SWEP:Reload() is being called, but occasionally the reload animation simply doesn’t work:

Is there something I should know here? Is this just some inexplicable fucking problem with dedicated servers, like SoundDuration() returning twice the real value?

Updated. The problem didn’t go away.

And then there’s this shit:

[lua]function SWEP:Reload()
– remove this line
if self.Reloading then return end

end
[/lua]

Removing the return works, for a given value of ‘success’. The reload animation works but if you hold +reload it hangs in the middle of the reload animation until you release the bind. It’s as if on dedicated servers the clientside animation just fails sometimes unless you call swep:SendWeaponAnim() a few dozen times.

I’d have done more troubleshooting myself but my hard drive started clicking this morning.

I’m in the same boat, will let you know if I come up with anything.

He’s probably figured it out by this time in all likelyhood.