SWEPs issue

Hey,
I have some sweps, but if you hit with it, the playeranimation doesn’t run. Also you can still drop it, which shouldn’t work.



AddCSLuaFile( "weapon_ttt_axe.lua" )

SWEP.HoldType			= "melee"

if CLIENT then
	SWEP.PrintName			= "Diamond Minecraft Sword"
	SWEP.Slot				= 0
	SWEP.DrawAmmo			= false
	SWEP.DrawCrosshair		= true
	SWEP.Icon = "VGUI/ttt/icon_cbar"   
	SWEP.ViewModelFOV = 54
end

local rDmg = math.random( 25, 50 )

SWEP.UseHands			= true
SWEP.Base				= "weapon_base"
SWEP.ViewModel			= "models/weapons/v_diamond_mc_sword.mdl"
SWEP.WorldModel			= "models/weapons/w_diamond_mc_sword.mdl"

SWEP.Weight			= 5
SWEP.AutoSwitchTo		= false
SWEP.AutoSwitchFrom		= false

SWEP.Primary.Damage = rDmg
SWEP.Primary.ClipSize		= -1
SWEP.Primary.DefaultClip	= -1
SWEP.Primary.Automatic		= true
SWEP.Primary.Delay = 1.2
SWEP.Primary.Ammo		= "none"

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= true
SWEP.Secondary.Ammo		= "none"
SWEP.Secondary.Delay = 5


SWEP.NoSights = true
SWEP.IsSilent = true

SWEP.AutoSpawnable = false

SWEP.AllowDelete = true -- never removed for weapon reduction
SWEP.AllowDrop = false

local sound_single = Sound("weapons/melee/crowbar/crowbar_hit-1.wav")
local sound_open = Sound("DoorHandles.Unlocked3")

function SWEP:PrimaryAttack()
   self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )

   if not IsValid(self.Owner) then return end

   if self.Owner.LagCompensation then -- for some reason not always true
      self.Owner:LagCompensation(true)
   end

   local spos = self.Owner:GetShootPos()
   local sdest = spos + (self.Owner:GetAimVector() * 70)

   local tr_main = util.TraceLine({start=spos, endpos=sdest, filter=self.Owner, mask=MASK_SHOT_HULL})
   local hitEnt = tr_main.Entity

	self.Weapon:EmitSound("Zombie.AttackMiss")

   if IsValid(hitEnt) or tr_main.HitWorld then
      self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
	  
	  if IsValid(hitEnt) then
		self.Weapon:EmitSound("Weapon_Crowbar.Melee_Hit")
	  elseif tr_main.HitWorld then
		self.Weapon:EmitSound(sound_single)
	  end
	    

      if not (CLIENT and (not IsFirstTimePredicted())) then
         local edata = EffectData()
         edata:SetStart(spos)
         edata:SetOrigin(tr_main.HitPos)
         edata:SetNormal(tr_main.Normal)

         --edata:SetSurfaceProp(tr_main.MatType)
         --edata:SetDamageType(DMG_CLUB)
         edata:SetEntity(hitEnt)

         if hitEnt:IsPlayer() or hitEnt:GetClass() == "prop_ragdoll" then
            util.Effect("BloodImpact", edata)

            -- does not work on players rah
            --util.Decal("Blood", tr_main.HitPos + tr_main.HitNormal, tr_main.HitPos - tr_main.HitNormal)

            -- do a bullet just to make blood decals work sanely
            -- need to disable lagcomp because firebullets does its own
            self.Owner:LagCompensation(false)
            self.Owner:FireBullets({Num=1, Src=spos, Dir=self.Owner:GetAimVector(), Spread=Vector(0,0,0), Tracer=0, Force=1, Damage=0})
         else
            util.Effect("Impact", edata)
         end
      end
   else
      self.Weapon:SendWeaponAnim( ACT_VM_MISSCENTER )
   end


   if CLIENT then
      -- used to be some shit here
   else -- SERVER

      -- Do another trace that sees nodraw stuff like func_button
      local tr_all = nil
      tr_all = util.TraceLine({start=spos, endpos=sdest, filter=self.Owner})
      
      self.Owner:SetAnimation( PLAYER_ATTACK1 )

      if hitEnt and hitEnt:IsValid() then
		self.Owner:SetAnimation( PLAYER_ATTACK1 )
         local dmg = DamageInfo()
         dmg:SetDamage(self.Primary.Damage)
         dmg:SetAttacker(self.Owner)
         dmg:SetInflictor(self.Weapon)
         dmg:SetDamageForce(self.Owner:GetAimVector() * 1500)
         dmg:SetDamagePosition(self.Owner:GetPos())
         dmg:SetDamageType(DMG_CLUB)

         hitEnt:DispatchTraceAttack(dmg, spos + (self.Owner:GetAimVector() * 3), sdest)

         self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )         

         self.Owner:TraceHullAttack(spos, sdest, Vector(-16,-16,-16), Vector(16,16,16), 30, DMG_CLUB, 11, true)
         self.Owner:FireBullets({Num=1, Src=spos, Dir=self.Owner:GetAimVector(), Spread=Vector(0,0,0), Tracer=0, Force=1, Damage=20})
      
      else
--         if tr_main.HitWorld then
--            self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
--         else
--            self.Weapon:SendWeaponAnim( ACT_VM_MISSCENTER )
--         end

         -- See if our nodraw trace got the goods
         if tr_all.Entity and tr_all.Entity:IsValid() then
            self:OpenEnt(tr_all.Entity)
         end
      end
   end

   if self.Owner.LagCompensation then
      self.Owner:LagCompensation(false)
   end
end

function SWEP:DrawWorldModel()
     self:DrawModel()
end

function SWEP:SecondaryAttack()
end

function SWEP:GetClass()
	return "weapon_zm_improvised"
end

function SWEP:OnDrop()
	self:Remove()
end



-snip-
I’m fucking blind, misunderstood the question.

Uhm isnt “PLAYER_ATTACK1” a standard anim?
“ACT_VM_HITCENTER” doesn’t work either

I’m unsure why the player animation isn’t working, but the ACT_VM_HITCENTER not working could mean that animation doesn’t exist within the weapons model file since that is a weapon animation. I may be wrong though.