ID:140876
 
Code:
world
view=8
name="Airsoft & Paintball"
New()
..()
Del()
..()

//SOUND EFFECTS!
var/const/SOUND_BERETTA92='Audio/Sound/Beretta92.ogg'
var/const/SOUND_UMP45='Audio/Sound/UMP45.ogg'
var/const/SOUND_PUMPSHOTGUN='Audio/Sound/PumpShotgun.ogg'
var/const/SOUND_RELOAD='Audio/Sound/reload.ogg'

mob/Stat()
.=..()
statpanel("Stats")
stat("Key:","[src.key]")
stat("Kills:","[src.kills]")
if(src.weapon)
stat("------[src.weapon.name]------")
stat("Fire-Rate:","[src.weapon.Firerate]")
stat("Reload-Rate:","[src.weapon.Reload_Time]")
stat("Fire Power:","[src.weapon.Fire_Power]")
stat("------Inventory------")
stat(src.contents)

mob
var/tmp

reloading=0
flicking=0
fired=0
kills=0
Death()
world<<"<b><font color=red>** [src] has ran out of lives **"
src.density=0
src.opacity=0
src.icon='blank.dmi'
var/obj/flag/A
A.loc=src.loc
src<< "you are now spectating"
return
proc
Reload()
if(!src.weapon){src.reloading=0;return}
var/i=src.weapon
src<<"<i><font size=2>Reloading..."
sleep(src.weapon.Reload_Time)
if(!src.weapon){src.reloading=0;return}
else if(i==src.weapon)
var/obj/Pickup/Ammo/A=locate(src.weapon.Ammo_Path) in src.contents
if(A)
view(src)<<sound(src.weapon.Reload_Sound,0)
var/take=src.weapon.MACapacity
take-=src.weapon.ACapacity
if(A.ammo<take)take=A.ammo
src.weapon.ACapacity+=take
src.weapon.suffix="[src.weapon.ACapacity]/[src.weapon.MACapacity]"
A.ammo-=take
if(A.ammo<=0)del(A)
else A.suffix="[A.ammo]/[A.mammo]"
src<<"<i><font size=2>...Reloaded!"
sleep(10)
src.reloading=0
LocateAmmo()
if(!src.weapon)return 0
var/A=locate(src.weapon.Ammo_Path) in src.contents
if(A)return 1
else return 0
verb
ReloadGun()
if(src.reloading)return
if(src.weapon)
if(src.LocateAmmo())
if(src.weapon.ACapacity<src.weapon.MACapacity)
src.reloading=1
src.Reload()
else src<<"You need more ammo."

obj
Pickup
Guns

var
ACapacity=0
MACapacity=0
Firerate=0
Fire_Power=0
Reload_Time=0
Reload_Sound=0
Fire_Sound=0
Flick_State=0
Ammo_Path=0
obj/Bullets/Bullet_Type=0
Beretta92
name="Beretta 92"
icon='Guns/Beretta92.dmi'
icon_state="Beretta 92"
ACapacity=12
MACapacity=12
Firerate=6
Fire_Power=50
Reload_Time=18
Fire_Sound=SOUND_BERETTA92
Reload_Sound=SOUND_RELOAD
Flick_State="lhandgun_fire"
Ammo_Path=/obj/Pickup/Ammo/Ammo


Problem description:

It said
weapon.MACapacity
weapon.ACapacity
weapon.Ammo_Path
weapon.suffix
weapon.Reload_Sound
weapon.Reload_Time
weapon.Firerate
weapon.name
hasn't been defined as a var
(there is more guns than just the beretta but i just showed the beretta)
can someone please take the code put it in the new environment and fix it please?
Not sure if I see the weapon var defined here, but it looks like you've got a simple case, I'll assume it's defined elsewhere.


Mostly, you're looking to type coerce(type cast) the weapon variable so that the compiler will treat it as a different type, allowing you to access such vars that the obj /obj/Guns has.

Here's an example of how to type cast:

obj/weapon
var/damage=5
proc/wielded(mob/ref) // you'll need to make appropriate calls here, of course
ref.weapon_wielded = src
ref << "You are now wielding [src]."
axe
damage=6

mob/var/weapon_wielded

mob/verb/display_weapon_damage()
if(!weapon_wielded) usr << "You have no weapon wielded!"
var/obj/weapon/A = usr.weapon_wielded
usr << "Your weapon is [A], it's damage is [A.damage]"


Be a bit careful when type casting, I'm not sure if DM prevents you from doing silly mistakes or not.
Ummmm.... That code looks just like Darker Emeralds codes, did you forget to copy the variables? *NOTE: You either used Darker Emerald's REO2 source or his demos either way it goes you need all of the codes to make it work appropriatly xD

On another note for everyone who reads this I found something that describes goto and gives us all a laugh xD

http://xkcd.com/292/