ID:146059
 
Code:
turf
Sell
Sell2
icon='other stuff.dmi'
icon_state="sell2"
name="Sell"
Click(var/obj/O in usr.contents)
switch(input("Are you sure you want to sell the [O] for [O.price]?")in list("Yes","No"))
if("Yes")
if(O.isequipped == 1)
usr << "Please unequip this item!"
if(O.whatitis=="Bone")
usr.bonesgot--
usr.Gold += O.price
del(O)
if(O.whatitis=="Fish")
usr.fish--
usr.Gold += O.price
del(O)
else
usr.Gold += O.price
del(O)
if("No")
usr<<"Okay!"


Problem description:
It returns with an error when I click the Sell button...

Uhh, Click doesn't take arguements like that.
In response to Hell Ramen
yeah try something like this
turf
Sell
Sell2
icon='other stuff.dmi'
icon_state="sell2"
name="Sell"
verb/Talk(var/obj/O in usr.contents)
switch(input("Are you sure you want to sell the [O] for [O.price]?")in list("Yes","No"))
if("Yes")
if(O.isequipped == 1)
usr << "Please unequip this item!"
if(O.whatitis=="Bone")
usr.bonesgot--
usr.Gold += O.price
del(O)
if(O.whatitis=="Fish")
usr.fish--
usr.Gold += O.price
del(O)
else
usr.Gold += O.price
del(O)
if("No")
usr<<"Okay!"
In response to JRR-Zero
if(O.isequipped == 1)
//should be
if(O.isequipped)

And "Talk"ing to an NPC would give you a list of objects in your inventory to talk to(although it would sell it if it passed the checks).
verb/Talk()
set category="Npc"
set src in oview(usr,1)
if(client)
switch(input("Welcome to my shop, [usr]!","Shop")in list("Buy","Sell","Cancel"))
if("Sell")
//etc Note: var/obj/O=locate(typesof(/obj)in usr.contents)
In response to Sinoflife
Sinoflife wrote:
> if(O.isequipped == 1)
> //should be
> if(O.isequipped)
>


While the latter is more robust, actually neither is right. For a var like that to exist, the equipment system has a major design flaw. There should never be a boolean var saying whether an item is equipped: Instead, the thing equipping it needs to keep track of which items it's using.

For simple equipment systems, that looks something like this:
mob
var/obj/item/weapon/weapon

The var is null if no weapon is in use, or otherwise will point to the weapon itself. Any weapon can very easily tell if it's equipped by 1) checking if its loc is a valid mob, and 2) if so, if it matches that mob's weapon var.

Much more complex systems are possible, but in all cases it's bad for the item itself to be in charge of keeping track of its equipment status.

Lummox JR
In response to Sinoflife
See, I would've done it the way where it gives you an input for a Talk verb, but I get the same problem doing that too..... I'll play with the code a bit and see. I have the merchant set up for "Buy" and "Sell" verbs, but I hate pop-up verbs, and was hoping there would be some way to stop that by using HUD-based merchants.
In response to Killerdragon
Okay, I figured out the problem, and I know how to fix it now.... Instead of usr.contents, I should use just usr.....

Thanks for the help guys....

Just for you guys, I will post up the mini-code I made in a couple seconds after I figured it out just to explain....

mob
verb
Test()
switch(input("What would you like to do?","Test") in list ("Buy","Sell","Cancel"))
if("Buy")
usr << "Sorry, nothing to buy...."
if("Sell")
var/obj/o = input("What would you like to sell?") in usr
switch(input("[usr], are you sure you would like to sell [o]","Sell [o]") in list ("Yes","No"))
if("Yes")
usr.Gold+=o.price
del(o)
if("No")
usr << "Okay..."
if("Cancel")
usr << "Okay..."


I believe that will work now for when I put it under a Click() procedure....