• Infinite ammo.
    3 replies, posted
Making Quake 4 pack, blaster is infinite here. Need help making it infinite in Garry's mod. That's the code: [code]SWEP.AdminSpawnable = true SWEP.ViewModelFOV = 50 SWEP.ViewModel = "models/weapons/v_q4blaster.mdl" SWEP.WorldModel = "models/weapons/w_pistol.mdl" SWEP.AutoSwitchTo = true SWEP.Slot = 3 SWEP.HoldType = "revolver" SWEP.PrintName = "Blaster" SWEP.Author = "" SWEP.Spawnable = true SWEP.AutoSwitchFrom = true SWEP.FiresUnderwater = true SWEP.Weight = 5 SWEP.DrawCrosshair = true SWEP.Category = "Quake 4" SWEP.SlotPos = 2 SWEP.DrawAmmo = true SWEP.Instructions = "" SWEP.Contact = "" SWEP.Purpose = "" SWEP.base = "weapon_base" SWEP.Primary.Sound = ("Quake4/fire01.wav") SWEP.Primary.Damage = 8 SWEP.Primary.TakeAmmo = 1 SWEP.Primary.ClipSize = -1 SWEP.Primary.Ammo = "none" SWEP.Secondary.Ammo = "none" SWEP.Primary.DefaultClip = -1 SWEP.Primary.Spread = 0.2 SWEP.Primary.NumberofShots = 1 SWEP.Primary.Automatic = true SWEP.Primary.Recoil = 0 SWEP.Primary.Delay = 0.3 SWEP.Primary.Force = 25 //SWEP:Initialize()\\ function SWEP:Initialize() util.PrecacheSound("Quake4/fire01.wav") util.PrecacheSound("Quake4/fire02.wav") util.PrecacheSound("Quake4/charge.wav") util.PrecacheSound("Quake4/charge_loop.wav") util.PrecacheSound("Quake4/charged_fire01.wav") util.PrecacheSound("Quake4/charged_fire02.wav") util.PrecacheSound("Quake4/charged_fire03.wav") util.PrecacheSound("Quake4/ready.wav") self:SetWeaponHoldType( self.HoldType ) end //SWEP:Initialize()\\ function SWEP:Deploy() self.Weapon:SendWeaponAnim(ACT_VM_DRAW) timer.Simple( 0.1, function() self.Weapon:EmitSound(Sound("Quake4/ready.wav"))end) return true end function SWEP:CanPrimaryAttack() return true end //SWEP:PrimaryFire()\\ function SWEP:PrimaryAttack() local bullet = {} bullet.Num = self.Primary.NumberofShots bullet.Src = self.Owner:GetShootPos() bullet.Dir = self.Owner:GetAimVector() bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0) bullet.Tracer = 0 bullet.Force = self.Primary.Force bullet.Damage = self.Primary.Damage bullet.AmmoType = self.Primary.Ammo local rnda = self.Primary.Recoil * -1 local rndb = self.Primary.Recoil * math.random(-1, 1) self:ShootEffects() self.Owner:FireBullets( bullet ) self:TakePrimaryAmmo(0) timer.Simple( 4, function() self.Weapon:SendWeaponAnim(ACT_VM_IDLE) end) self.Weapon:EmitSound(Sound(self.Primary.Sound)) local soundnumber = math.random(1,2) if soundnumber == 1 then self.Weapon:EmitSound("Quake4/fire01.wav") else self.Weapon:EmitSound("Quake4/fire02.wav") end self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) ) self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay ) end function SWEP:SecondaryAttack() local bullet = {} bullet.Num = 1 bullet.Src = self.Owner:GetShootPos() bullet.Dir = self.Owner:GetAimVector() bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0) bullet.Tracer = 0 bullet.Force = 50 bullet.Damage = 50 bullet.AmmoType = self.Primary.Ammo local rnda = self.Primary.Recoil * -1 local rndb = self.Primary.Recoil * math.random(-1, 1) self.Weapon:SendWeaponAnim(ACT_VM_ATTACH_SILENCER) self:ShootEffects() self.Owner:FireBullets( bullet ) local soundnumber = math.random(1,3) if soundnumber == 1 then self.Weapon:EmitSound("Quake4/charged_fire01.wav") if soundnumber == 2 then self.Weapon:EmitSound("Quake4/charged_fire02.wav") else self.Weapon:EmitSound("Quake4/charged_fire03.wav") end self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) ) self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay ) end end /*--------------------------------------------------------- Reload ---------------------------------------------------------*/ function SWEP:Reload() return false end[/code] Not that Secondary isn't yet finished.
I don't see the problem, it should already be infinite? Also you might want to remove this line - self:TakePrimaryAmmo(0) - it's useless.
It is, but it doesn't fire, just plays a sound with animation.
I just tested your function and it is working, so I don't know what are you talking about.
Sorry, you need to Log In to post a reply to this thread.