ID:166755
 
if("Sell")
var/v=input("Please select the item you wish to sell.") in list ("Bag","Nevermind")
if(v=="Nevermind")
usr<<"[src]: Quit wasting my time!"
if(v=="Bag")
var/i=input("Which item do you wish to sell?") in usr.contents
set src in usr.contents


this is all i can think of, im stuck from this point. I want the usr to be able to choose an item from their inventory, see how much they can get for it, and be able to sell the item and get gold.
make a value = [the weapons value here] var for every item and then make the shop give the amount put for the bvalue var the gold they get when they sell it.
obj/var/price
mob/shopkeeper/Click()
var/obj/o=input("What do you wish to sell?",src) in null|usr //in usr, or in his contents, it's all the same.
// The null will add a cancel button.
if(!o){usr<<"[src]: Stop waisting my time!";return} // If o is nothing, or the usr pressed cancel.
switch(alert("I can get ya [o.price] gold for that. Do it?",src,"Yes","No"))
if("Yes")
usr.gold+=o.price
o.Move(src) // Or del(o), depends what system you want.
usr<<"[src]: Thank you, come again." // Quicky mart!
In response to Mysame
Mysame wrote:
> obj/var/price
> mob/shopkeeper/Click()
> var/obj/o=input("What do you wish to sell?",src) in null|usr //in usr, or in his contents, it's all the same.
> // The null will add a cancel button.
> if(!o){usr<<"[src]: Stop waisting my time!";return} // If o is nothing, or the usr pressed cancel.
> switch(alert("I can get ya [o.price] gold for that. Do it?",src,"Yes","No")
> if("Yes")
> usr.gold+=o.price
> o.Move(src) // Or del(o), depends what system you want.
> usr<<"[src]: Thank you, come again." // Quicky mart!



Yeah, there are a few mistakes you made.
mob/shopkeeper/Click()
var/obj/o=input("What do you wish to sell?",src) as null|anything in usr //in usr, or in his contents, it's all the same.
// The null will add a cancel button.
if(!o){usr<<"[src]: Stop waisting my time!";return} // If o is nothing, or the usr pressed cancel.
switch(alert("I can get ya [o.price] gold for that. Do it?",src,"Yes","No"))
if("Yes")
usr.gold+=o.price
o.Move(src) // Or del(o), depends what system you want.
usr<<"[src]: Thank you, come again." // Quicky mart!


Fixed them. I'm pretty sure that you'll have to make your own list like for() loop through the contents and find all of the /objs and add them to a different list. I think there is a way to make it so you can do something like as type(/obj) but I couldn't get that to work. Anyways, yeah.
In response to Justin B
Whoopsie, didn't notice I missed a parent. Anyhow, I never saw much use in using <code>as</code>. :/
And I never added it to a list ... Or I plainly can't remember. Anyhow, it works, normally. o.o
In response to Mysame
yay....I got it too work, thx for the example

except for, when you sell, there in the list is also a '' which i'm assuming is the actuall player. How would i get rid of this?
In response to FriesOfDoom
Normally there ain't something like that.. Then try what Justin said

as obj in null|usr
In response to Mysame
Mysame wrote:
Normally there ain't something like that.. Then try what Justin said

> as obj in null|usr


that worked
In response to FriesOfDoom
The fantom " represents the choice of null since you don't cary a null in your inventory.
Add 'null' to your list and make it called " " like this...

as null|anything in usr.contents +"" // Sell anything you've got on you + the Nothing called "" that doesn't show up



For more info on the Nothing please see: The Never Ending Story.
<^> Asha LaPoe