• Gmod help, ammo clips non existant?
    19 replies, posted
I fire my guns and as soon as the clip is done it just keeps firing and the clip is back to full, repeats. Unlimited firing basically. I'm not even sure where to look for something like this. Any help would be greatly appreciated! I'm trying to run Fortwars Onslaught which is an abandoned game mode that was released at some point. Files are here: Fort Wars Gamemode, Maps and Misc. i have zero experience with Lua files so please dumb anything/everything down for me :3 I'm having other issues too but 1 thing at a time.
SWEP.Primary.DefaultClip = SWEP.Primary.ClipSize * 9999 😂
i tried changing that to 300, just before i posted this thread but it didnt change anything I'll try setting it to the same in game clip size of 30.
https://youtu.be/g3TXTUYjRA0
Anymore ideas? I Really want to get this gamemode running and bring it back. I tried changing that 9999 ammo to 30 and as soon as the clip ran out it no longer reloads but still shoots infinitely.
The base you are using may have a strange reload hook within it, check the base SWEP as it may not even be calling for reload animations to be sent.
honestly just get rid of this line: SWEP.Primary.DefaultClip = SWEP.Primary.ClipSize * 9999 I don't see any use for it. The clip size is already determined a couple lines above that there shouldn't be a need to define it once again as "default". SWEP.Primary.ClipSize = 30 This line already in the code should be sufficient. Seems like whoever made the SWEP was attempting something and forgot to edit it out, probably trying to give it an endless clip so... mission accomplished I suppose.
What file is this base SWEP you're referring to? What i see is this, im entirely new to this so you may as well be talking to a newbie. I have a basic understanding of code but dont understand most of it. I'm learning as i go, very slowly. By very basic, i mean i read key words and hope area's of code have lots of keywords so i think i know what its doing lol. https://files.facepunch.com/forum/upload/326093/c1dcfa41-d343-4354-9f3b-c5e713d9dbed/fortwars1.png
The base swep of yours is SWEP.Base = "darkland_base" check that base and see if there are any reload hooks in it that mess with reload times
Okay so having that line of code does 2 things, from what i can tell. It makes the ammo GUI pop up and shows how many bullets you have. Without the code there is no ammo gui it controls the total amount of ammo you have, that first set of 30 is just the clip size whereas the 9999 is like a total amount of ammo you have that you never see.
Does the shotgun have anything related to reloading in it? Would help a ton because there is a SWEP.NextReload value in the base, though it is not used anywhere
yeah i saw a couple reload area's, ill bold them from the whole code if SERVER then   AddCSLuaFile( "shared.lua" ) end if CLIENT then   SWEP.PrintName     = "Boomstick"   SWEP.Author    = "Onslaught"   SWEP.Slot          = 2   SWEP.SlotPos       = 1   SWEP.DrawCrosshair = false end SWEP.Base               = "darkland_base" SWEP.HoldType = "shotgun" SWEP.ViewModel          = "models/weapons/v_shot_xm1014.mdl" SWEP.WorldModel         = "models/weapons/w_shot_xm1014.mdl" SWEP.Primary.Sound      = Sound( "Weapon_XM1014.Single" ) SWEP.Primary.Recoil            = 2 SWEP.Primary.Damage            = 4 SWEP.Primary.NumShots        = 16 SWEP.Primary.Cone            = 0.225 SWEP.Primary.ClipSize        = 2 SWEP.Primary.Delay            = .025 SWEP.Primary.DefaultClip    = SWEP.Primary.ClipSize * 9999 SWEP.Primary.Automatic        = false SWEP.Primary.Ammo            = "BuckShot" SWEP.Secondary.Recoil            = 4 SWEP.Secondary.ClipSize        = -1 SWEP.Secondary.DefaultClip    = -1 SWEP.Secondary.Automatic    = false SWEP.Secondary.Ammo            = "none" SWEP.Secondary.Delay        = 5 SWEP.Secondary.Sound        = Sound("weapons/shotgun/shotgun_dbl_fire.wav") if CLIENT then NextShotty = 0 end function SWEP:Initialize()     self:SetHoldType( self.HoldType ) end --RIPPED OUT OF THE CSS GUN, I DID NOT MAKE THIS function SWEP:Reload()     if ( self.Weapon:GetNetworkedBool( "reloading", false ) ) then return end     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     self.Weapon:SetNextPrimaryFire( CurTime() + 3 ) end function SWEP:PrimaryAttack()     self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )     self.Weapon:SetNextSecondaryFire( CurTime() + 3 )          self.Owner.NextShotty = self.Owner.NextShotty or 0     if SERVER and self.Owner.NextShotty > CurTime() then return end     if CLIENT and NextShotty > CurTime() then return end          // Play shoot sound     self.Weapon:EmitSound( self.Primary.Sound )     self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )         // View model animation     self.Owner:MuzzleFlash()                                // Crappy muzzle light     self.Owner:SetAnimation( PLAYER_ATTACK1 )                // 3rd Person Animation     // Shoot the bullet     self:CSShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone )          // Remove 1 bullet from our clip     self:TakePrimaryAmmo( 1 )          // Punch the player's view     self.Owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) )     NextShotty = CurTime() + 0.95     self.Owner.NextShotty = CurTime() + 0.95     self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )          if self.Weapon:Clip1() < 1 then         self:Reload()     end end function SWEP:SecondaryAttack()     self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )          if SERVER then         net.Start("cooldown")         net.WriteInt(self.Weapon:GetNextSecondaryFire(), 32)         net.Send(self.Owner)     end     --draw the cooldown bar     if CLIENT then              net.Receive("cooldown", function(len)             local nextfire = net.ReadInt(32)             local cooloff = vgui.Create( "DPanel" )             function cooloff:Paint( w, h )                 draw.RoundedBox( 8, 0, 0, w, h, Color( 0, 150, 0 ) )             end                          function cooloff:Think()                                             cooloff:SetSize( 50*(math.ceil(CurTime()-nextfire-1)*-1), 20  )                 end                     cooloff:SetPos(ScrW() - 290, ScrH() - 100)              end)     end          self.Owner.NextShotty = self.Owner.NextShotty or 0     if SERVER and self.Owner.NextShotty > CurTime() then return end     if CLIENT and NextShotty > CurTime() then return end          // Play shoot sound     if self.Weapon:Clip1() > 1 then         self.Weapon:EmitSound( self.Secondary.Sound )     else         self.Weapon:EmitSound( self.Primary.Sound )     end          self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )         // View model animation     self.Owner:MuzzleFlash()                                // Crappy muzzle light     self.Owner:SetAnimation( PLAYER_ATTACK1 )                // 3rd Person Animation          // Shoot the bullet     self:CSShootBullet( self.Primary.Damage, self.Primary.Recoil, (self.Primary.NumShots*tonumber(self.Weapon:Clip1())), self.Primary.Cone )          // Remove all bullets from our clip     self:TakePrimaryAmmo( self.Weapon:Clip1() )          // Punch the player's view     self.Owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Secondary.Recoil, math.Rand(-0.1,0.1) *self.Secondary.Recoil, 0 ) )     NextShotty = CurTime() + 0.95     self.Owner.NextShotty = CurTime() + 0.95     self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )          if self.Weapon:Clip1() < 1 then         self:Reload()     end end 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:SetVar( "reloadtimer", CurTime() + 0.3 )             self.Owner:GetViewModel():SetPlaybackRate( .2 )             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
Alright then you have some code to work with now, add all of that I’m to your SWEP that you put in bold and see what happened. Obviously something might be wrong though because it was designed for a shotgun and will only add 1 bullet per cycle but it should be simply to work around.
Okay so that did indeed do something different this time. From the video below you will see that when it runs out of ammo it does stop shooting but only because the gun is reloading the clip. If you just keep holding the fire button like i did for the second round of shooting in the video, it infinite fires again as its always reloading the wep. These issues are obviously cause its for a shotgun haha. Its a start! Thanks for helping me get this far!
I think if i can get the unlimited firing fixed, that would set me on the right path.
@vyserage what happens if you revert to the original code you have and set your code to this: SWEP.Primary.ClipSize = 30 SWEP.Primary.Delay = 0.1 SWEP.Primary.DefaultClip = 30 SWEP.Primary.Automatic = true SWEP.Primary.Ammo = "SMG1" SWEP.Secondary.ClipSize = 1 SWEP.Secondary.DefaultClip = 1
The code you suggested up above, i tried the changes but nothing different. Okay so the HasSpecial code is for the right click abilities of each class, nothing to worry about really. Thats not what is causing the insane fast reloading, im still unsure of what is. I've made small progress by adding in some of the code that was in the base, over into the code with the swat gun. This is what i added to the bottom of swat_gun -- Settings cooldown = 4 -- Cooldown period in Seconds -- Reload function with cooldown local lastReloadTime=0; function SWEP:Reload()     if ((os.time()-lastReloadTime)>cooldown) then -- Allows only after cooldown time is over         self.Weapon:DefaultReload( ACT_VM_RELOAD );         lastReloadTime=os.time() -- Sets this time as last using time of Reload     end end /*---------------------------------------------------------     PrimaryAttack ---------------------------------------------------------*/ SWEP.nextFire = 0 SWEP.lastFire = 0 function SWEP:PrimaryAttack()                         if self.nextFire > CurTime() then return end         self.nextFire = CurTime() + self.Primary.Delay         self.lastFire = CurTime()     // Play shoot sound     self.Weapon:EmitSound( self.Primary.Sound )     self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )         // View model animation     self.Owner:MuzzleFlash()                                // Crappy muzzle light     self.Owner:SetAnimation( PLAYER_ATTACK1 )                // 3rd Person Animation     // Shoot the bullet     self:CSShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone )          // Remove 1 bullet from our clip     self:TakePrimaryAmmo( 1 )          // Punch the player's view     self.Owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) )                    if ( self.Weapon:Clip1() <= 0 ) then         self:EmitSound( "Weapon_Pistol.Empty" )         self:SetNextPrimaryFire( CurTime() + 2.1 )         self:Reload()         return false     end     return true end With that code, it stops shooting when 0 clip but only because the cooldown from the code at top is making it have a reload cooldown of 4 seconds. Its definitely not ideal, but its getting me closer i guess. I've been working on it for like 6 hours now (no joke) and this is as far as i've gotten -.- Even had my cousin helping and still not a whole lot of luck haha.
Not gonna lie, can't be bothered to look through everything everyone has said on the issue, so if you think I'm being dumb and ignorant, yeah I am. I've had an issue like this before, and the issue was that the server didn't have the models, and therefore didn't know how long to run the reload for, because it doesn't have the animations with the model. Those are most definitely CS:S models, they don't have a c_hands and look like they should, (and I see the model path now lol) so here's what I can guess from both of those issues: The server does not have CS:S mounted.
This would honestly make the most sense... the models and animations seem really fucked. I just watched the video he provided and the pistol doesn't even really seemed to be rigged (the slide doesn't come back at all when firing), and the M4a1 or w/e the attachment flies off the gun whenever it's fired also.
Haha sounds like progress to me! Thanks for chiming in! How would i go about mounting css?
Sorry, you need to Log In to post a reply to this thread.