Chessnut / NutScript

A free role-play framework for Garry's Mod.
http://nutscript.rocks
MIT License
94 stars 77 forks source link

Once ammo hits 0, the weapon regains a full magazine if you die or respawn #472

Closed smt923 closed 9 years ago

smt923 commented 9 years ago

Basically whenever the ammo for a gun is 0 you can instantly regain a full magazine (the weapon starts with a magazine inside too, which probably shouldn't happen, but whatever) by respawning or killing your self. The ammo stays saved at 0 if you reequip, drop, re-character select or rejoin. Any positive value of ammo stays through deaths.

Latest nutscript 1.1 and hl2rp 1.1 schema, nothing custom that should be touching the ammo system, and no errors

koen24 commented 9 years ago

I'd like to elaborate on this issue. The amount of bullets in a weapon's clip is only saved to the item when you unequip the item (sh_weapons.lua, line 51) but not on death/disconnecting/reloading. So if you have 4 bullets, shoot one, and you die, you will have 4 bullets in your gun again. If you have 4 bullets, shoot one, then unequip and re-equip your weapon, and then die, you will have 3 bullets, like you should.

Should be easy to fix by saving the amount of bullets in the gun to its item whenever the player dies, disconnects or loads another character. Alternatively, a system could be written that constantly updates the item's ammo.