[TTT] Nyan Gun Help

Hey guys I got the nyan gun working on a server however I really would like to edit it a bit…mainly to get rid of the ‘Infinite Ammo’ thing however no matter what I have thrown in so far, it still stays at infinite ammo.

Can someone take a look at the LUA and see what I have to remove to make it so players have to reload and run out of ammo?



if ( SERVER ) then
	AddCSLuaFile()

	
	
resource.AddFile("sound/weapons/nyan/nya2.mp3")
resource.AddFile("sound/weapons/nyan/nyan_loop.mp3")
resource.AddFile("sound/weapons/nyan/nyan_beat.mp3")
resource.AddFile("sound/weapons/nyan/nya1.mp3")
resource.AddFile("materials/nyan/killicon2.png")
resource.AddFile("materials/nyan/cat_reversed.png")
resource.AddFile("materials/nyan/rainbow.vmt")
resource.AddFile("materials/nyan/killicon.vtf")
resource.AddFile("materials/nyan/killicon.png")
resource.AddFile("materials/nyan/selection.png")
resource.AddFile("materials/nyan/rainbow.vtf")
resource.AddFile("materials/nyan/killicon_bomb.vmt")
resource.AddFile("materials/nyan/rainbow.png")
resource.AddFile("materials/nyan/cat.vtf")
resource.AddFile("materials/nyan/killicon_bomb.vtf")
resource.AddFile("materials/nyan/killicon.vmt")
resource.AddFile("materials/nyan/cat.vmt")
resource.AddFile("materials/nyan/cat.png")
resource.AddFile("materials/entities/weapon_nyangun.png")
 

end

if ( CLIENT ) then
	
	SWEP.SlotPos = 0

	killicon.Add( "weapon_nyangun", "nyan/killicon", color_white )
	SWEP.WepSelectIcon = Material( "nyan/selection.png" )
	SWEP.BounceWeaponIcon = false
	SWEP.DrawWeaponInfoBox = false
end

   SWEP.EquipMenuData = {
      name = "NyanGun",
      type = "item_weapon",
      desc = "Shoots Nyan Cats"
   };
   SWEP.Slot = 2
SWEP.Kind = WEAPON_HEAVY
--SWEP.CanBuy = {ROLE_DETECTIVE, ROLE_TRAITOR}
SWEP.LimitedStock = false
SWEP.Icon = "entities/weapon_nyangun.png" 

SWEP.Base = "weapon_tttbase"
SWEP.PrintName = "Nyan Gun"
SWEP.Category = "Robotboy655's Weapons"
SWEP.ViewModel = "models/weapons/v_smg1.mdl"
SWEP.WorldModel = "models/weapons/w_smg1.mdl"
SWEP.Spawnable = false
SWEP.AdminSpawnable = false
SWEP.AutoSpawnable = false
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.HoldType = "smg"
SWEP.AmmoEnt = "item_ammo_pistol_ttt"

SWEP.ViewModelFlip = false

SWEP.Primary.ClipSize = 50
SWEP.Primary.Delay = 0.1
SWEP.Primary.DefaultClip = 1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "Pistol"
SWEP.Primary.ClipMax     = 150
SWEP.Primary.DefaultClip = 50

SWEP.Secondary.ClipSize = 50
SWEP.Secondary.Delay = 0.5
SWEP.Secondary.DefaultClip = 1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "Pistol"	
SWEP.Secondary.ClipMax     = 150
SWEP.Secondary.DefaultClip = 50

function SWEP:Initialize()
	self:SetWeaponHoldType( self.HoldType )
end

function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )
	surface.SetDrawColor( 255, 255, 255, alpha )
	surface.SetMaterial( self.WepSelectIcon )
	surface.DrawTexturedRect( x + 10, y, 128, 128 )
end

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

	if (self.Owner:IsNPC()) then
		self:EmitSound( "weapons/nyan/nya" .. math.random( 1, 2 ) .. ".mp3", 100, math.random( 60, 80 ) )
	else
		if ( self.LoopSound ) then
			self.LoopSound:ChangeVolume( 1, 0.1 )
		else
			self.LoopSound = CreateSound( self.Owner, Sound( "weapons/nyan/nyan_loop.mp3" ) )
			if ( self.LoopSound ) then self.LoopSound:Play() end
		end
		if ( self.BeatSound ) then self.BeatSound:ChangeVolume( 0, 0.1 ) end
	end

	local bullet = {}
	bullet.Num = 1
	bullet.Src = self.Owner:GetShootPos()
	bullet.Dir = self.Owner:GetAimVector()
	bullet.Spread = Vector( 0.01, 0.01, 0 )
	bullet.Tracer = 1
	bullet.Force = 5
	bullet.Damage = 8 
	//bullet.AmmoType = "Ar2AltFire" -- For some extremely stupid reason this breaks the tracer effect
	bullet.TracerName = "rb655_nyan_tracer"
	self.Owner:FireBullets( bullet )

	self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
	self.Owner:SetAnimation( PLAYER_ATTACK1 )

	self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
	self:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
end

function SWEP:SecondaryAttack()
	if ( !self:CanSecondaryAttack() ) then return end
	self:EmitSound( "weapons/nyan/nya" .. math.random( 1, 2 ) .. ".mp3", 100, math.random( 85, 100 ) )

	local bullet = {}
	bullet.Num = 6
	bullet.Src = self.Owner:GetShootPos()
	bullet.Dir = self.Owner:GetAimVector()
	bullet.Spread = Vector( 0.10, 0.1, 0 )
	bullet.Tracer = 1
	bullet.Force = 10
	bullet.Damage = 25		
	//bullet.AmmoType = "Ar2AltFire"
	bullet.TracerName = "rb655_nyan_tracer"
	self.Owner:FireBullets( bullet )

	self.Weapon:SendWeaponAnim( ACT_VM_SECONDARYATTACK )
	self.Owner:SetAnimation( PLAYER_ATTACK1 )

	self.Weapon:SetNextPrimaryFire( CurTime() + self.Secondary.Delay )
	self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay ) 
end

--function SWEP:Reload()
--	if ( !self.Owner:KeyPressed( IN_RELOAD ) ) then return end
--	if ( self:GetNextPrimaryFire() > CurTime() ) then return end
--	
--	if ( SERVER ) then
--		local ang = self.Owner:EyeAngles()
--		local ent = ents.Create( "ent_nyan_bomb" )
--		if ( IsValid( ent ) ) then
--			ent:SetPos( self.Owner:GetShootPos() + ang:Forward() * 28 + ang:Right() * 24 - ang:Up() * 8 )
--			ent:SetAngles( ang )
--			ent:SetOwner( self.Owner )
--			ent:Spawn()
--			ent:Activate()
--			
--			local phys = ent:GetPhysicsObject()
--			if ( IsValid( phys ) ) then phys:Wake() phys:AddVelocity( ent:GetForward() * 1337 ) end
--		end
--	end
--	
--	self:SendWeaponAnim( ACT_VM_SECONDARYATTACK )
--	self.Owner:SetAnimation( PLAYER_ATTACK1 )
--	
--	self:EmitSound( "weapons/nyan/nya" .. math.random( 1, 2 ) .. ".mp3", 100, math.random( 60, 80 ) )
--	
--	self:SetNextPrimaryFire( CurTime() + 1 )
--	self:SetNextSecondaryFire( CurTime() + 1 ) 
--end

function SWEP:DoImpactEffect( trace, damageType )
	local effectdata = EffectData()
	effectdata:SetStart( trace.HitPos )
	effectdata:SetOrigin( trace.HitNormal + Vector( math.Rand( -0.5, 0.5 ), math.Rand( -0.5, 0.5 ), math.Rand( -0.5, 0.5 ) ) )
	util.Effect( "rb655_nyan_bounce", effectdata )

	return true
end

function SWEP:FireAnimationEvent( pos, ang, event )
	return true
end

function SWEP:KillSounds()
	if ( self.BeatSound ) then self.BeatSound:Stop() self.BeatSound = nil end
	if ( self.LoopSound ) then self.LoopSound:Stop() self.LoopSound = nil end
end

function SWEP:OnRemove()
	self:KillSounds()
end

function SWEP:OnDrop()
	self:KillSounds()
end

function SWEP:Deploy()
	self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
	self.Weapon:SetNextPrimaryFire( CurTime() + self.Weapon:SequenceDuration() )
	
	if ( CLIENT ) then return true end

	--self.BeatSound = CreateSound( self.Owner, Sound( "weapons/nyan/nyan_beat.mp3" ) )
	--if ( self.BeatSound ) then self.BeatSound:Play() end

	return true
end

function SWEP:Holster()
	self:KillSounds()
	return true
end

function SWEP:Think()
	if ( self.Owner:IsPlayer() && self.Owner:KeyReleased( IN_ATTACK ) ) then
		if ( self.LoopSound ) then self.LoopSound:ChangeVolume( 0, 0.1 ) end
		if ( self.BeatSound ) then self.BeatSound:ChangeVolume( 1, 0.1 ) end
	end
end


No, stop putting it on TTT, it is a terrible idea.

You forgot:
[lua]
self:TakePrimaryAmmo(1)
[/lua]

I figured by keeping it the same then yes it would be a terrible idea but getting rid of the infinite ammo, the high speed firing and actually making it somewhat like a real gun, players actually would love this feature. Plus, it is a point shop gun to buy rather then it being spawned. I just figured something different then the same old stuff would help spice things up for the players.

Either way; @buu342, I am comparing this to other default guns and no other guns have that line in there yet the gun still reloads.

I will continue to look into it and figure it out, just thought someone would point me in the right direction. Looking at wiki now.

The reason is that the takeprimaryammo is inside the weapon base. Since you rewrote the primary attack function it will forget the one from the base. Parts of the code dont just appear magically.

And by “something different” you mean the stupidest weapon in GMod that is on most TTT servers anyway?

Well you are entitled to your opinion Robotboy. When I initially added it, the players reactions showed otherwise.

Thanks buu342.