Infinite Ammo Bug

I am running darkRP for a couple years now, never had this problem and suddenly I get this:


[ERROR] gamemodes/darkrp/entities/entities/spawned_weapon/init.lua:30: attempt to perform arithmetic on local 'amount' (a nil value)
1. DecreaseAmount - gamemodes/darkrp/entities/entities/spawned_weapon/init.lua:30
2. unknown - gamemodes/darkrp/entities/entities/spawned_weapon/init.lua:82


I use M9K and fixed the ammo bug a long time ago where you make the clips the same sizes.

When you drop the gun it looks like this:

And you can pick it up as many times as you want.

Code found here: https://github.com/FPtje/DarkRP/blob/master/entities/entities/spawned_weapon/init.lua

self.dt.amount is nil. I don’t see you setting it anywhere in the code you posted.

The easy way to fix the error is to change line 28 to:
[lua]local amount = self.dt.amount or 5[/lua]
Where 5 is some default amount you’d assume the weapon has if the value isn’t found.

The correct way to fix it is to figure out where the value is supposed to be initialized, and do it there.

The thing is, its the same of shipments as well, and I don’t think changing darkrp core files is the way to go.

Oh, I didn’t realize your link was to DarkRP code and not something that you have on your server :S

I guess you should wait for FPtje to see this, maybe he’d know :slight_smile:

Yeah, I made a ticket on github but just an urgent bug. Thanks for trying though :slight_smile: