Need some help with VElements.

SWEP.VElements = {
[“silencer”] = { type = “Model”, model = “models/items/combine_rifle_ammo01.mdl”, bone = “Base”, rel = “”, pos = Vector(-0.06, -0.004, 26.656), angle = Angle(-5.69, 13.095, -1.265), size = Vector(0.735, 0.598, 1.324), color = Color(0, 0, 0, 255), surpresslightning = false, material = “”, skin = 0, bodygroup = {} }
}

Where do i exatcly paste this in? When ever i paste it in the bottom of my code, i don’t see the model and i don’t get any errors.

Your weapon must be based ( SWEP.Base ) on the swep construction base as far as I know ( which also must be present on the server in order for your weapon to work. )

if CLIENT then

language.Add(“weapon_ar2_silencer”, “AR2 (Silenced)”)

SWEP.PrintName = “AR2 (Silenced)”
SWEP.Category = “Half-Life 2”
SWEP.Slot = 1
SWEP.SlotPos = 2
SWEP.DrawAmmo = true
SWEP.DrawCrosshair = true
SWEP.ViewModelFOV = 60
SWEP.ViewModelFlip = false
SWEP.HoldType = “smg”

end

SWEP.ViewModel = “models/weapons/ar2sil/v_irifle.mdl”
SWEP.WorldModel = “models/weapons/w_irifle.mdl”

SWEP.Spawnable = true
SWEP.AdminSpawnable = false

SWEP.Primary.Recoil = 2
SWEP.Primary.ClipSize = 30
SWEP.Primary.DefaultClip = 60
SWEP.Primary.Automatic = true
SWEP.Primary.Delay = 0.05
SWEP.Primary.Ammo = “ar2”

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = “none”
SWEP.UseHands = true

SWEP.Zoom = 0

function SWEP:Initialize()

end

function SWEP:Deploy()
if(self.Zoom == 0) then
self.Weapon:SendWeaponAnim(ACT_VM_DRAW);
self:SetNextPrimaryFire( CurTime() + self:SequenceDuration())
self:SetNextSecondaryFire( CurTime() + self:SequenceDuration())
self:NextThink( CurTime() + self:SequenceDuration() )
self:Idle()
self.Zoom = 0
return true

else
if(self.Zoom == 1) then
self.Weapon:SendWeaponAnim(ACT_VM_DRAW_SILENCED);
	self:SetNextPrimaryFire( CurTime() + self:SequenceDuration())
	self:SetNextSecondaryFire( CurTime() + self:SequenceDuration())
	self:NextThink( CurTime() + self:SequenceDuration() )
	self:Idle()
	self.Zoom = 1
	return true

	end
end

end

function SWEP:Holster()
self.Owner:SetFOV( 0, 0 )
self.Zoom = 0

return true

end

function SWEP:Holster( wep )
if ( CLIENT ) then return end

self:StopIdle()
return true

end

function SWEP:Reload( )
if ( self:Clip1() < self.Primary.ClipSize && self.Owner:GetAmmoCount( self.Primary.Ammo ) > 0 ) then
if self:Clip1() <= 29 then
if(self.Zoom == 0) then
self.Weapon:DefaultReload(ACT_VM_RELOAD)
self:EmitSound("")
self:Idle()
self.Zoom = 0
elseif self:Clip1() <= 29 then
if(self.Zoom == 1) then
self.Weapon:DefaultReload(ACT_VM_RELOAD_SILENCED)
self:EmitSound("")
self:Idle()
self.Zoom = 1
end
end
end
end
end

function SWEP:Think()
if ( self.Owner:KeyReleased( IN_ATTACK ) || ( !self.Owner:KeyDown( IN_ATTACK ) && self.Sound ) ) then
self:Idle()
end
if ( self.Owner:KeyReleased( IN_ATTACK2 ) || ( !self.Owner:KeyDown( IN_ATTACK2 ) && self.Sound ) ) then
self:Idle()
end
end

function SWEP:PrimaryAttack()
if self:IsUnderWater() then return end
if ( !self:CanPrimaryAttack() ) then return end

		if (self.Zoom == 0 || self:Clip1() &lt; 1 ) then
		self:SetWeaponHoldType("smg")
	self:ShootBullet( 10, 1, 0.01 )
	self.Weapon:SetNextPrimaryFire( CurTime() + 0.09 )
	self:EmitSound( Sound("weapons/ar2sil/m4a1-1.wav") )
	self:TakePrimaryAmmo( 1 )
    self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
	self.Owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) )
	else
		
		if (self.Zoom == 1 || self:Clip1() &lt; 1 ) then
		self:SetWeaponHoldType("smg")
	self.Weapon:SetNextPrimaryFire( CurTime() + 0.3 )
	self:ShootBullet( 10, 1, 0.02 )
	self:EmitSound( Sound("weapons/ar2sil/m4a1-1.wav") )
	self:TakePrimaryAmmo( 1 )
    self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK_SILENCED)
	self.Owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) )
		end
	end
end

function SWEP:IsUnderWater()
if self:WaterLevel() < 3 then
return false
else
if SERVER then
return true
end
end
end

function SWEP:DoIdleAnimation()
if (self.Zoom == 0) then self:SendWeaponAnim( ACT_VM_IDLE ) return end
if (self.Zoom == 1) then self:SendWeaponAnim( ACT_VM_HITLEFT ) return end
end

function SWEP:DoIdle()
self:DoIdleAnimation()

timer.Adjust( "weapon_idle" .. self:EntIndex(), self:SequenceDuration(), 0, function()
	if ( !IsValid( self ) ) then timer.Destroy( "weapon_idle" .. self:EntIndex() ) return end

	self:DoIdleAnimation()
end )

end

function SWEP:StopIdle()
timer.Destroy( “weapon_idle” … self:EntIndex() )
end

function SWEP:Idle()
if ( CLIENT || !IsValid( self.Owner ) ) then return end
timer.Create( “weapon_idle” … self:EntIndex(), self:SequenceDuration() - 0.2, 1, function()
if ( !IsValid( self ) ) then return end
self:DoIdle()
end )
end

If you can, show me where SWEP.Base must be placed. That would help me a lot.

Copy the base_code.lua file from SCK into your SWEP’s folder, and add this in your SWEP’s code:

[lua]
AddCSLuaFile(“base_code.lua”)
include(“base_code.lua”)
[/lua]

Thanks :slight_smile: Thanks a lot.