• SWEP animation doesn't work
    3 replies, posted
SWEP animation doesn't work. Why and how to fix it? AddCSLuaFile() SWEP.Author                    = "MS-DOS" SWEP.Base                    = "weapon_gfists" SWEP.PrintName                = "Fists" SWEP.Instructions            = [[Left-Click: to eat]] SWEP.ViewModel                 = Model( "models/weapons/c_arms.mdl" ) SWEP.ViewModelFlip            = false SWEP.UseHands                = true SWEP.WorldModel                 = "" SWEP.SetHoldType            = "fist" SWEP.Weight                    = 5 SWEP.AutoSwitch                = true SWEP.AutoSwitchFrom            = false SWEP.Slot                    = 0 SWEP.SlowPos                = 4 SWEP.DrawAmmo                = false SWEP.DrawCrosshair            = false SWEP.Spawnable                = false SWEP.AdminSpawnable            = true SWEP.Primary.ClipSize         = -1 SWEP.Primary.DefaultClip     = -1 SWEP.Primary.Automatic         = true SWEP.Primary.Ammo             = "none" SWEP.Secondary.ClipSize        = -1 SWEP.Secondary.DefaultClip     = -1 SWEP.Secondary.Automatic     = true SWEP.Secondary.Ammo         = "none" SWEP.DrawAmmo                = false SWEP.HitDistance             = 48 SWEP.ShouldDropOnDie        = true local SwingSound = Sound("Weapon_Crowbar.Single") local HitSound = Sound("Weapon_Crowbar.Melee_Hit") function SWEP:Initialize()     self:SetHoldType( "fist" ) end function SWEP:PrimaryAttack()     if (CLIENT) then return end     local ply = self:GetOwner()     ply:LagCompensation (true)     local shootpos = ply:GetShootPos()     local endshootpos = shootpos + ply:GetAimVector() * 70     local tmin = Vector(1,1,1) * -10     local tmax = Vector(1,1,1) * 10          local tr = util.TraceHull({         start = shootpos,         endpos = endshootpos,         filter = ply,         mask = MASK_SHOT_HULL,         mins = tmax     })          if(not IsValid(tr.Entity)) then         tr = util.TraceLine({         start = shootpos,         endpos = endshootpos,         filter = ply,         mask = MASK_SHOT_HULL         })     end     local ent = tr.Entity          if (IsValid(ent) && (ent:IsPlayer() || ent:IsNPC())) then         self.Weapon:SendWeaponAnim(ACT_GESTURE_FLINCH_LEFTARM)         ply:SetAnimation(PLAYER_ATTACK1)         ply:EmitSound(HitSound)         ent:SetHealth(ent:Health() - 5)         if (ent:Health()<1) then             ent:Kill()         end                  ply:SetHealth(math.Clamp(ply:Health() + 5))     elseif (!IsValid(ent)) then         self.Weapon:SendWeaponAnim(ACT_GESTURE_FLINCH_LEFTARM)         ply:SetAnimation(PLAYER_ATTACK1)         ply:EmitSound(SwingSound)     end         self:SetNextPrimaryFire(CurTime() + self:SequenceDuration() + 0.1)     ply:LagCompensation (false) end function SWEP:OnDrop()     self:Remove() -- You can't drop fists end function SWEP:Deploy()     local speed = GetConVarNumber( "sv_defaultdeployspeed" )     local vm = self.Owner:GetViewModel()     vm:SendViewModelMatchingSequence( vm:LookupSequence( "fists_draw" ) )     vm:SetPlaybackRate( speed )     self:SetNextPrimaryFire( CurTime() + vm:SequenceDuration() / speed )     self:SetNextSecondaryFire( CurTime() + vm:SequenceDuration() / speed )     return true end function SWEP:CanSecondaryAttack()     return false end
Duplicated thread ;) -- When you are doing SWEP.SetHoldType = "fist" -- ... function SWEP:Initialize() self:SetHoldType( "fist" ) -- This won't do anything, because you set SWEP.SetHoldType to string, not function end I think it should work if you remove SWEP.SetHoldType = "fist"
No. It doesn't work
You are using a function value like a variable, and it makes me cringe. SWEP.SetHoldType = "fist" SWEP Structure
Sorry, you need to Log In to post a reply to this thread.