ID:177488
 
I'm trying to make it so i dont have to type in the price for buying an item for every shop. I have a variable for the price of each item. but I cant seem to use it. can someone help?

mob
Townsmen8
typechar = "ShopKeeper"
name = "SHOPBOY2K"
var/obj/armor/MetalArmor/S
var/obj/armor/BasicArmor/F
verb
speak()
set src in oview(1)
switch(input("What do u want","weapons") in list("Basic Armor", "Metal Armor"))
if("Basic Armor")
switch(input("Are you sure","weapons") in list("yes","no"))
if("yes")
if(usr.gold < 125)
return
else
usr.gold -= 125
new/obj/armor/BasicArmor(usr)
usr << "You get a Basic armor"
if("no")
return
if("Metal Armor")
switch(input("Are you sure you want Metal Armor","weapons") in list("Yes","no"))
if("Yes")
usr.gold -= 500
new/obj/armor/MetalArmor(usr)
usr << "You get a Metal Armor"
if("no")
usr<<"You do not have enough gold"
return
icon = 'Townsman1.dmi'

KiteShield
basetype = "shield"
defense = 3
durability = 75
price = 90
please help?
How long is a gour?
In response to Garthor
One jay!
Probably the best way to handle shopkeeper mobs is with a list of wares that they sell.

obj/var/price
mob/var/cash

mob/Shopkeeper
var/list/wares

Dan_The_Shopkeeper
wares = list(/obj/Sword, /obj/Armour)

verb/Buy()
set src in oview(1)
var/O = input("What do ya want to buy?") in wares
var/obj/P = new O
if(P.price > src.cash)
src << "Sorry, not enough cash"
return
src.cash -= P.price
src.contents.Add(P)
src << "There you go."
return

obj
Sword
price = 100
Armour
price = 150

Hope that helps. :)