ID:147808
 
The get verb used to work all fine and dandy, but just recently, it quit working on me. If the gun is already in my inventory, it adds the ammo like it should, but if the gun is not in my inventory, it does nothing.
                Get()
set src in oview(0)
for(var/obj/Weapon/Deringer/D in usr.contents)
if(!D)
if(Move(usr))
usr << "You pick up the [src]"
return
else
usr << "You cannot pick up the [src]"
return
D.maxclip += rand(1,10)
if(D.maxclip >= 16)
D.maxclip = 15
del(src)
return
Enigmaster2002 wrote:
for(var/obj/Weapon/Deringer/D in usr.contents)
if(!D)
...
You've got all your code inside that for() loop, when what you need to do is do the loop first, then do the src.Move(usr) bit if there wasn't a gun to reload (or there wasn't enough room left in the clip).

Also, the if(!D) part will never execute.

Here's what you need instead:
obj/item/ammo
var/guntype
var/ammo

Get()
if(!usr.Enter(src) || !loc.Exit(src))
usr << "You can't pick up [src]."
return
for(var/obj/item/Weapon/W in usr)
if(!istype(W, guntype)) continue
if(W.ammo < W.maxammo)
var/fill = min(W.maxammo - W.ammo, ammo)
W.ammo += fill
if(fill >= ammo) del(src) // verb stops here
ammo -= fill
// some ammo is left
var/obj/item/ammo/A = locate(type) in usr
if(A)
A.ammo += ammo
del(src)
loc = usr

Lummox JR
In response to Lummox JR
Well, what's wierd about it is that it worked peachy until yesterday, then bam; Get doesn't work. But yours does, thanks for the help.