mob/npc/buying_npc
icon = 'buying-npcs.dmi'
density = 1
maxHealth = 100000
health = 100000
defense = 2
strength = 4
name = "Dealer"
exp = 15
verb/shop() //this verb still needs a lot of work, get the items in a list to make it easier
set src in view(1)
usr << "You enter the shop."
var/choice = input(usr,"Select your deal type?","Shop") in list ("Buy","Sell","Leave")
if(choice == "Buy")
var/buying_choice = input(usr,"What would you like to buy?","Shop") in list ("Sword","Shield","Nothing")
if(buying_choice == "Sword")
var/item_and_cost = input(usr,"This item cost 30 gold, will you still buy it?","Shop") in list ("Yes","No")
if(item_and_cost == "Yes" && usr.gold >= 30)
usr.gold -= 30
usr.contents += new /obj/Sword
//missing the shield
if(item_and_cost == "No")
usr << "You decide to buy nothing."
return
if(buying_choice == "Nothing")
usr << "You decide to buy nothing."
return
//there is still more, the shied, you need to find out how to make the items in a list
if(choice == "Sell")
var/selling_choice = input(usr,"What would you like to sell?","Shop") in list (src in usr.contents,"Nothing")
if(selling_choice == src in usr.contents)
var/next_selling_choice = input(usr,"Will you sell this for [src.selling_gold]?") in list ("Yes","No")
if(next_selling_choice == "Yes" && usr.gold >= src.selling_gold)
usr.gold -= src.selling_gold
usr.contents += src
else
usr << "You do not have enough gold."
return
if(next_selling_choice == "No")
var/next_choice = input(usr,"Would you like to leave the shop?","Shop") in list ("Yes","No")
if(next_choice == "Yes")
usr << "You leave the shop."
return
if(selling_choice == "Nothing")
usr << "You decide not to sell."
return
if(choice == "Leave")
usr << "You leave the shop."
return
Problem description:Ok, now the problem with this code is that at the buying part, where it shows the choices "Sword","Shield", I want it so I can have a list of the items that are available (I don't care, as long as it is a better way to store items), that way I can use src and if usr.gold >= src.gold then they can buy it. Also, at the selling part, I need it to list the usr.contents some kinda way or show what they have in their contents available to sell (any object). I've tried a few things.
I think this may be what you want...