How do I make this sweps world animations work?

I am very close to getting done with my newest project and have run into a slight error which is really bugging me.

Basically when I get the swep in game my player holds the knife like a pistol in 3rd person, or world model rather.

SO… I need to get him to hold the weapon like a crowbar. How would I go about modifying this lua to make this work properly. I have already added proper bones to my world model so that should not pose a problem.

Here is some fun code.

I did not make it and I don’t know who did, it is some doug guy, But I am not much of an lua scripter.


if( SERVER ) then
	AddCSLuaFile( "shared.lua" )
	SWEP.HoldType			= "melee"
end

if( CLIENT ) then
	SWEP.PrintName = "Iron Knife"
	SWEP.Slot = 3
	SWEP.SlotPos = 3
	SWEP.DrawAmmo = false
	SWEP.DrawCrosshair = false
end

SWEP.Author			= "Doug Tyrrell"
SWEP.Instructions	= "Left click to stab, right click to throw!"
SWEP.Contact		= "www.dvondrake.com"
SWEP.Purpose		= ""

SWEP.ViewModelFOV	= 62
SWEP.ViewModelFlip	= false

SWEP.Spawnable			= false
SWEP.AdminSpawnable		= true

SWEP.NextStrike = 0;
  
SWEP.ViewModel      = "models/morrowind/iron/knife/v_firstknife.mdl"
SWEP.WorldModel   = "models/morrowind/iron/knife/w_firstknife.mdl"
  
-------------Primary Fire Attributes----------------------------------------
SWEP.Primary.Delay			= 0.9 	--In seconds
SWEP.Primary.Recoil			= 0		--Gun Kick
SWEP.Primary.Damage			= 15	--Damage per Bullet
SWEP.Primary.NumShots		= 1		--Number of shots per one fire
SWEP.Primary.Cone			= 0 	--Bullet Spread
SWEP.Primary.ClipSize		= -1	--Use "-1 if there are no clips"
SWEP.Primary.DefaultClip	= -1	--Number of shots in next clip
SWEP.Primary.Automatic   	= true	--Pistol fire (false) or SMG fire (true)
SWEP.Primary.Ammo         	= "none"	--Ammo Type
 
-------------Secondary Fire Attributes-------------------------------------
SWEP.Secondary.Delay		= 0.9
SWEP.Secondary.Recoil		= 0
SWEP.Secondary.Damage		= 0
SWEP.Secondary.NumShots		= 1
SWEP.Secondary.Cone			= 0
SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic   	= true
SWEP.Secondary.Ammo         = "none"

util.PrecacheSound("weapons/knife/morrowind_knife_deploy1.wav")
util.PrecacheSound("weapons/knife/morrowind_knife_hitwall1.wav")
util.PrecacheSound("weapons/knife/morrowind_knife_hit.wav")
util.PrecacheSound("weapons/knife/morrowind_knife_slash.wav")

function SWEP:Initialize()
	self.Hit = { 
	Sound( "weapons/knife/knife_hitwall1.wav" )}
	self.FleshHit = {
  	Sound("weapons/knife/morrowind_knife_hit.wav") }
end

function SWEP:Precache()
end

function SWEP:Deploy()
	self.Owner:EmitSound("weapons/knife/morrowind_knife_deploy1.wav")
	return true
end

function SWEP:PrimaryAttack()
	if( CurTime() < self.NextStrike ) then return; end
	self.NextStrike = ( CurTime() + .5 )
 	local trace = self.Owner:GetEyeTrace()
	if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 75 then
		if( trace.Entity:IsPlayer() or trace.Entity:IsNPC() or trace.Entity:GetClass()=="prop_ragdoll" ) then
			self.Owner:EmitSound( self.FleshHit[math.random(1,#self.FleshHit)] )
		else
			self.Owner:EmitSound( self.Hit[math.random(1,#self.Hit)] )
		end
			self.Owner:SetAnimation( PLAYER_ATTACK1 )
			self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
				bullet = {}
				bullet.Num    = 1
				bullet.Src    = self.Owner:GetShootPos()
				bullet.Dir    = self.Owner:GetAimVector()
				bullet.Spread = Vector(0, 0, 0)
				bullet.Tracer = 0
				bullet.Force  = 1
				bullet.Damage = 25
			self.Owner:FireBullets(bullet) 
	else
		self.Owner:SetAnimation( PLAYER_ATTACK1 )
		self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
		self.Weapon:EmitSound("weapons/knife/morrowind_knife_slash.wav")
	end
end

function RemoveKnife( ent )
	if ent:IsValid() then
		ent:Remove()
	end
end

function SWEP:SecondaryAttack()
	if( CurTime() < self.NextStrike ) then return; end
	self.NextStrike = ( CurTime() + 1 )
 
    self.Owner:SetAnimation( PLAYER_ATTACK1 );
	self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER );
	self.Weapon:EmitSound("weapons/knife/morrowind_knife_slash.wav")
	self.Owner:EmitSound("weapons/knife/morrowind_knife_deploy1.wav")
   
	local tr = self.Owner:GetEyeTrace()
	
	if (!SERVER) then return end;
	
	local ent = ents.Create ("thrownknife")

	ent:SetPos (self.Owner:EyePos() + (self.Owner:GetAimVector() * 16))
	ent:SetAngles (self.Owner:EyeAngles())
	ent:Spawn()
	
	ent.Thrower = self.Owner

	local phys = ent:GetPhysicsObject()

	local shot_length = tr.HitPos:Length()
	phys:ApplyForceCenter (self.Owner:GetAimVector():GetNormalized() * math.pow (shot_length, 3))

	cleanup.Add (self.Owner, "props", ent)

	undo.Create ("Knife")
	undo.AddEntity (ent)
	undo.SetPlayer (self.Owner)
	undo.Finish()
	
	timer.Simple(20, RemoveKnife, ent) 
end 


Everything works fine except for the world animations, help?


(User was banned for this post ("Wrong forum" - Grea$eMonkey))

SWEP.Holdtype = “melee2”)

That did not work. I got the same exact results.

Edit: I tried changing it to nearly every hold type, none of them work.

Try making SWEP.Holdtype shared instead of server.

That did not seem to work either.

I think I may have found something important, I went and downloaded css realistic weapons to see if I could use that base instead, and Before doing anything to the pack it showed the knife as being held like a gun… What the hell?

I am going to clear my addons, I have no idea if there is a conflicting mod or what.

NVM: Google is my friend, I found this facepunch thread actually. Should have searched first before posting I guess.

Instead of this


function SWEP:Initialize()
    if SERVER then
        self:SetWeaponHoldType("melee")
    end
end

It needed to be this


function SWEP:Initialize()
    self:SetWeaponHoldType("melee")
end

I need to fix up my W_Models now. Thanks for trying to help me peoples hope this helps anyone with similar problems.