ID:262782
 
Code:
mob
proc
Sell_Stuff()
switch(input("Would you like to sell something?") in list ("Yes","No"))
if("Yes")
input(usr,"What item do you want to sell?","Inventory") in usr.contents
..()
if("No")
return


Problem description:
first, i doesn't open up the usr inventory, and two, what do i have to put in there to make it delete the item chosen.
plz show me plz this will help me lots
Pyro_dragons wrote:
Code:
mob
> proc
> Sell_Stuff()
> switch(input("Would you like to sell something?") in list ("Yes","No"))
> if("Yes")
> input(usr,"What item do you want to sell?") in usr.contents
> ..()
> if("No")
> return
>


you dont use commas in a code, it can result in problems.
In response to Developous
could you show me a modified version of my code to make it work right? you know, it shows you whats in your inventory, then you choose an item, it is delelted from your inventory, then you get the value of the item added to your gold. plz help and or show me plz plz plz this would help a lot.
In response to Developous
Dont use usr in procs, repleace with src. and set src in view(1)
In response to Xx Dark Wizard xX
there is nothing wrong with this, but it deletes all the items in the usrs inventory, which i don't want. i just want it to delete the item they specified. how can i do that?
mob
proc
Sell_Stuff()
switch(input("Would you like to sell something?") in list ("Yes","No"))
if("Yes")
set src in oview(1)
var/a = input("What item to do want to sell?",usr.contents)
var/b = input("[a] is worth 0 gold. Do you still want to sell it?") in list("Yes","No")
if(b == "Yes")
for(var/obj/D in usr.contents)
del(D)
if("No")
return
In response to Pyro_dragons
for(var/obj/D in usr.contents)
del(D)

thats why.

make an input thats lists all the contents. make the selected item d and use del(D)
In response to Xx Dark Wizard xX
please use
tags around code

ok then what should it be? if i just put del(a) i get a runtime error and it doesn't delete the item.
In response to Pyro_dragons
I noticed a bit of usr abuse in the proc, so I re-did it for ya'.
mob
proc
Sell_Stuff()
switch(input(src,"Would you like to sell something?") in list ("Yes","No"))//input defaults to usr, dont forget to set src in a proc
if("Yes")
var/a = input(src,"What item to do want to sell?") in src.contents + list ("Cancel")
if(a!="Cancel")
switch(input(src,"[a] is worth 0 gold. Do you still want to sell it?") in list ("Yes","No"))
if("Yes")
del(a)


Tested, worked fine.
In response to Detnom
I'd use this

mob
proc
Sell_Stuff()
switch(input(src,"Would you like to sell something?") in list ("Yes","No"))
if("Yes")
var/b = list(src.contents)
var/a = input(src,"What item to do want to sell?") in b + list ("Cancel")
if(a!="Cancel")
for(var/obj/O in src.contents)
if(O==a)
switch(input(src,"[O] is worth [O.amount] cash. Do you still want to sell it?") in list ("Yes","No"))
if("Yes")
del(O)


So it doesn't sell for 0 gold o.o
In response to Mysame
i hae no errors, but both of your changes give me runtime eroor and nullify the sell stuff proc.
In response to Pyro_dragons
nevermind, i figured it out myself. Thanks for trying though guys.