Wrong weapon position on custom models

Hello,
I have a little problem with my cs:go weapons. They are not in the hand of the custom playermodels, for example sometimes in the head and sometimes somewhere else. But if I take a normal standard TTT weapon, they are in the hand. So the mistake must be in the code of the weapon. There is also an error in the console: “attempt to call method ‘SetRenderOrigin’ (a nil value)”
Here is one lua file:


local soundData = {
    name 		= "Weapon_Cm4a1.Clipout" ,
    channel 	= CHAN_WEAPON,
    volume 		= 0.25,
    soundlevel 	= 80,
    pitchstart 	= 100,
    pitchend 	= 100,
    sound 		= "newage_csgo/CsGO/m4a1/m4a1_clipout.wav"
}

sound.Add(soundData)

local soundData = {
    name 		= "Weapon_Cm4a1.Clipin" ,
    channel 	= CHAN_WEAPON,
    volume 		= 0.25,
    soundlevel 	= 80,
    pitchstart 	= 100,
    pitchend 	= 100,
    sound 		= "newage_csgo/CsGO/m4a1/m4a1_clipin.wav"
}
sound.Add(soundData)

local soundData = {
    name 		= "Weapon_Cm4a1.BoltForward" ,
    channel 	= CHAN_WEAPON,
    volume 		= 0.25,
    soundlevel 	= 80,
    pitchstart 	= 100,
    pitchend 	= 100,
    sound 		= "newage_csgo/CsGO/m4a1/m4a1_boltforward.wav"
}

sound.Add(soundData)

local soundData = {
    name 		= "Weapon_Cm4a1.BoltBack" ,
    channel 	= CHAN_WEAPON,
    volume 		= 0.25,
    soundlevel 	= 80,
    pitchstart 	= 100,
    pitchend 	= 100,
    sound 		= "newage_csgo/CsGO/m4a1/m4a1_boltback.wav"
}

sound.Add(soundData)

local soundData = {
    name 		= "Weapon_Cm4a1.Draw" ,
    channel 	= CHAN_WEAPON,
    volume 		= 0.25,
    soundlevel 	= 80,
    pitchstart 	= 100,
    pitchend 	= 100,
    sound 		= "newage_csgo/CsGO/m4a1/m4a1_draw.wav"
}

sound.Add(soundData)

if ( SERVER ) then

	AddCSLuaFile( "shared.lua" )
	
end


SWEP.PrintName			= "M4A4"
SWEP.Slot				= 2
SWEP.SlotPos			= 1

SWEP.HoldType			= "ar2"
SWEP.ViewModelFlip		= false
SWEP.ViewModel			= "models/weapons/newage_csgo/c_csgo_m4a1.mdl"
SWEP.WorldModel			= "models/weapons/newage_csgo/csgo_world/w_rif_m4a1.mdl"
SWEP.UseHands			= true
SWEP.ViewModelFOV		= 54

SWEP.Weight				= 5
SWEP.AutoSwitchTo		= false
SWEP.AutoSwitchFrom		= false
SWEP.DrawCrosshair		= false		-- set false if you want no crosshair

-- TTT settings
SWEP.Spawnable		= true
SWEP.AdminSpawnable = true
SWEP.AutoSpawnable	= true
SWEP.Kind			= WEAPON_HEAVY
SWEP.AmmoEnt 		= "item_ammo_pistol_ttt"
SWEP.IsSilent 		= false
SWEP.NoSights 		= false
SWEP.Base 			= "weapon_tttbase"
SWEP.AllowDrop		= true
-- TTT

SWEP.Primary.Sound 		= Sound("newage_csgo/csgo/m4a1/m4a1_unsil-1.wav")
SWEP.Primary.Recoil			= 1
SWEP.Primary.Damage			= 29
SWEP.Primary.NumShots		= 1
SWEP.Primary.Cone			= 0.01
SWEP.Primary.ClipSize		= 30
SWEP.Primary.ClipMax		= 60
SWEP.Primary.DefaultClip	= 30
SWEP.Primary.Delay			= 0.12
SWEP.HeadshotMultiplier 	= 2
SWEP.Primary.Spread		= 0.06
SWEP.Primary.KickUp				= 0.5		-- Maximum up recoil (rise)
SWEP.Primary.KickDown			= 0.4		-- Maximum down recoil (skeet)
SWEP.Primary.KickHorizontal		= 0.4		-- Maximum up recoil (stock)
SWEP.Primary.Automatic	 	= true
SWEP.Primary.Ammo			= "pistol"

SWEP.IronSightsPos = Vector(-5, -8.712, 0.72)

SWEP.IronSightsAng = Vector(-0.076, 0.14, 0)

SWEP.RunArmOffset = Vector (0.5,-2.5,-1)

SWEP.RunArmAngle = Vector (-10,35,-2)

-- Accuracy
-- Accuracy
SWEP.CrouchCone				= 0.01 -- Accuracy when we're crouching
SWEP.CrouchWalkCone			= 0.02 -- Accuracy when we're crouching and walking
SWEP.WalkCone				= 0.025 -- Accuracy when we're walking
SWEP.AirCone				= 0.1 -- Accuracy when we're in air
SWEP.StandCone				= 0.015 -- Accuracy when we're standing still
SWEP.Delay				= 0.1
SWEP.Recoil				= 0
SWEP.RecoilZoom			= 0

if CLIENT then
   SWEP.Icon = "vgui/ttt/m4a4_newage"
end

function SWEP:PreDrop()
   self:SetIronsights(false)
   return self.BaseClass.PreDrop(self)
end

function SWEP:Holster()
   self:SetIronsights(false)
   return true
end

SWEP.Offset = {
   Pos = {
      Up = 0,
      Right = 1,
      Forward = -3,
   },
   Ang = {
      Up = 0,
      Right = 0,
      Forward = 0,
   }
}

function SWEP:Think()
        self:DrawWorldModel( )
end
 
function SWEP:RenderOverride()
        self:DrawWorldModel()
end
 
function SWEP:OnDrop()
        self.Owner = nil
end

function SWEP:Reload()
   self.Weapon:DefaultReload( ACT_VM_RELOAD );
   self:SetIronsights( false )
end

function SWEP:DrawWorldModel( )
local hand, offset, rotate
 
if not IsValid( self.Owner ) then      
        self:SetRenderOrigin(self.Pos)
        self:SetRenderAngles(self.Ang)
        self:DrawModel( )
return
end
 
if not self.Hand then
 	  self.Hand = self.Owner:LookupAttachment( "anim_attachment_rh" )
end
 
hand = self.Owner:GetAttachment( self.Hand )
 
if not hand then
   	--self:SetRenderOrigin(self:GetNetworkOrigin())
 	  --self:SetRenderAngles(self:GetNetworkAngles())
  	 self:SetRenderOrigin(self.Pos)
  	 self:SetRenderAngles(self.Ang)
  	 self:DrawModel( )
   	return
end
 
offset = hand.Ang:Right( ) * self.Offset.Pos.Right + hand.Ang:Forward( ) * self.Offset.Pos.Forward + hand.Ang:Up( ) * self.Offset.Pos.Up
 
hand.Ang:RotateAroundAxis( hand.Ang:Right( ), self.Offset.Ang.Right )
hand.Ang:RotateAroundAxis( hand.Ang:Forward( ), self.Offset.Ang.Forward )
hand.Ang:RotateAroundAxis( hand.Ang:Up( ), self.Offset.Ang.Up )
 
if self.SetRenderOrigin == nil or self.SetRenderAngles == nil then return end
 
self:SetRenderOrigin( hand.Pos )
self:SetRenderAngles( hand.Ang )
 
self:DrawModel( )
end

I hope you can help me.

Maksimo007

Maksimo007 ist ein super dolll:overyourhead: