ID:145607
 
Code: Short Reload-With-Clip code.
obj/Clip
icon = 'Guns.dmi'
icon_state = "Clip"
Pickup = 1
weapon = 0
verb/Reload()
if (usr.gun/ammo != usr.gun/maxammo)
if (usr.gun == "Uzi")
view() << 'Uzi Reload.wav'
sleep(21)
//How can I call a usr.gun's ammo?
return
if (usr.gun == "USSCOM")
view() << 'USSCOM Reload.wav'
sleep(9)
//How can I call a usr.gun's ammo?
return
view() << "[usr.gun] reloaded."
del(src)


Problem description: Simple. In the IF command usr.gun/ammo seemed to work, but it won't outside. How can I call it?

What I need done: To just call that damn Ammo var. It should all work if it wasn't for it.
obj/Clip
icon = 'Guns.dmi'
icon_state = "Clip"
Pickup = 1
weapon = 0
verb/Reload()
if(usr.weapon in typesof(/obj/Guns))
if(usr.weapon.ammo!=usr.weapon.maxammo)
var/list/guns=list(/obj/Guns/Uzi=list("Sound"='Uzi Reload.wav',"Sleep"=21),/obj/Guns/USSCOM=list("Sound"='USSCOM Reload.wav',"Sleep"=9))
view()<<sound(guns[usr.weapon]["Sound"])
sleep(guns[usr.weapon]["Sleep"])
usr<<"[(usr.weapon in typesof(/obj/Guns))?"[usr.weapon] reloaded.":""]"
del src
In response to Artemio
Code failed - I should of said it was usr.gun ... The guns were not in obj/Guns either... And now the whole point of the code fails after I tweaked it. I'll see if I can do the tweak differently.


EDIT: Bah.. it don't work. I'll see if I can do some different code. My Life As A Spy style?
Wait wait wait, to me, that's saying that you're dividing gun by ammo and gun by max ammo.

Are you just trying to access the vars? If so, you'll want to replace "/" with "."
In response to Audeuro
I tried that first, it didn't work.
In response to RedlineM203
mob/verb/obj/gun

Then on equipping a gun, you put
usr.gun=src


Make sure /obj/gun has an ammo var;

usr.gun.ammo=30
In response to Mysame
I said I wasn't using that way anymore.
In response to RedlineM203
Quiter >:(