ID:149645
 
here is my code i need to be able to give the gold back to the player when i sell but i dont know how i should define the object

proc/sell()
var/which_item = input(usr,"Which item do you wish to sell?", ", src.goldvalue") in usr.contents
usr.gold += goldvalue //here is da problem what do i put to make it give you back the items worth
del(which_item)
Mrhat99au wrote:
here is my code i need to be able to give the gold back to the player when i sell but i dont know how i should define the object

proc/sell()
var/which_item = input(usr,"Which item do you wish to sell?", ", src.goldvalue") in usr.contents
usr.gold += goldvalue //here is da problem what do i put to make it give you back the items worth
del(which_item)

It depends on how you determine an object's value in the game. If you store it in the object itself (one good way to go), then you can do something like this:
obj
var/value
proc/sell()
var/obj/what
what = input("Sell which item?", "Sell") in usr.contents
if(what)
if(alert("Sell [what] for [what.value]?",,"Yes","No") == "Yes")
usr.gold += what.value
del(what)
usr << "You sold [what]."


This will work if you store the value in the object where it is appropriate.