I hold a shotgun like a pistol...

Hello world! I just redo the gun hl2 named Annabelle, I have not changed my style but I just fixed the bugs, but here it yours annabelle like a gun! I’m sure I put this line of code: SWEP.HoldType = “ar2”
But still want the weapon as a pistol. Can anyone tell me correct this commercial? Thank you!

Make sure the holdtype and the function to set the holdtype are being shared between the server and client.

I think it’s ok, this is the server and client code:

if ( SERVER ) then

AddCSLuaFile( "shared.lua" )

SWEP.HoldType			= "ar2"

end

if ( CLIENT ) then

SWEP.PrintName			= "Annabelle"			
SWEP.Author				= "Lyc@n"
SWEP.Slot				= 4
SWEP.SlotPos			= 3
SWEP.IconLetter			= "k"

SWEP.DrawCrosshair		= true
SWEP.ViewModelFlip		= false

end
Thanks!

Move the SWEP.HoldType variable out of the if (SERVER) check.

Like this: if ( SERVER ) then

AddCSLuaFile( "shared.lua" )

end

SWEP.HoldType			= "ar2"

if ( CLIENT ) then

SWEP.PrintName			= "Annabelle"			
SWEP.Author				= "Lyc@n"
SWEP.Slot				= 4
SWEP.SlotPos			= 3
SWEP.IconLetter			= "k"

SWEP.DrawCrosshair		= true
SWEP.ViewModelFlip		= false

end

That don’t work.

Show us your SWEP:Initialize function

here is the full code:

if ( SERVER ) then

AddCSLuaFile( "shared.lua" )

end

if ( CLIENT ) then

SWEP.PrintName			= "Annabelle"			
SWEP.Author				= "Lyc@n"
SWEP.Slot				= 4
SWEP.SlotPos			= 3
SWEP.IconLetter			= "k"

SWEP.DrawCrosshair		= true
SWEP.ViewModelFlip		= false
SWEP.HoldType			= "ar2"

end

SWEP.Category = “RP Weapons”

SWEP.Spawnable = true
SWEP.AdminSpawnable = true

SWEP.ViewModel = “models/weapons/v_shotgun.mdl”
SWEP.WorldModel = “models/weapons/w_annabelle.mdl”

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

SWEP.Primary.Sound = Sound( “Weapon_M3.Single” )
SWEP.Primary.Recoil = 5
SWEP.Primary.Damage = 20
SWEP.Primary.NumShots = 1
SWEP.Primary.Cone = 0.05
SWEP.Primary.ClipSize = 2
SWEP.Primary.Delay = 0.95
SWEP.Primary.DefaultClip = 32
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = “357”

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

SWEP.IronSightsPos = Vector (-10.8993, -8.8412, 5.6549)
SWEP.IronSightsAng = Vector (-2.9336, -2.2212, -5.752)

/---------------------------------------------------------
Reload does nothing
---------------------------------------------------------
/
function SWEP:Reload()

//if ( CLIENT ) then return end

// Already reloading
if ( self.Weapon:GetNetworkedBool( "reloading", false ) ) then return end

// Start reloading if we can
if ( self.Weapon:Clip1() < self.Primary.ClipSize && self.Owner:GetAmmoCount( self.Primary.Ammo ) > 0 ) then
	
	self.Weapon:SetNetworkedBool( "reloading", true )
	self.Weapon:SetVar( "reloadtimer", CurTime() + 0.3 )
	self.Weapon:SendWeaponAnim( ACT_VM_RELOAD )
	
end

end

/---------------------------------------------------------
Think does nothing
---------------------------------------------------------
/
function SWEP:Think()

if ( self.Weapon:GetNetworkedBool( "reloading", false ) ) then

	if ( self.Weapon:GetVar( "reloadtimer", 0 ) < CurTime() ) then
		
		// Finsished reload -
		if ( self.Weapon:Clip1() >= self.Primary.ClipSize || self.Owner:GetAmmoCount( self.Primary.Ammo ) <= 0 ) then
			self.Weapon:SetNetworkedBool( "reloading", false )
			return
		end
		
		// Next cycle
		self.Weapon:SetVar( "reloadtimer", CurTime() + 0.3 )
		self.Weapon:SendWeaponAnim( ACT_VM_RELOAD )
		
		// Add ammo
		self.Owner:RemoveAmmo( 1, self.Primary.Ammo, false )
		self.Weapon:SetClip1(  self.Weapon:Clip1() + 1 )
		
		// Finish filling, final pump
		if ( self.Weapon:Clip1() >= self.Primary.ClipSize || self.Owner:GetAmmoCount( self.Primary.Ammo ) <= 0 ) then
			self.Weapon:SendWeaponAnim( ACT_SHOTGUN_RELOAD_FINISH )
		else
		
		end
		
	end

end

end

Thanks!

**[Weapon.SetWeaponHoldType

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Weapon.SetWeaponHoldType)** Perhaps?

I will try this, thanks.

[lua]
function SWEP:Initialize()
self:SetWeaponHoldType(self.HoldType)
return true
end[/lua]

That work! Thank you everyone! :slight_smile: