ID:147954
 
I'm trying to make it so you can talk to an NPC and they talk back. And to sell them something you say "Sell"
but for some reason it trys to sell the usr instead of
opening a list of their items =(

Here's my code:

mob/verb
shopsay(msg as text)
view(6)<<"[usr]:[msg]"
if(msg == "Hi" && usr.nearshop == 1)
usr<<"Shopkeeper: Hi"
usr.nearshop = 2
if(msg == "Buy" && usr.nearshop == 2)
usr<<"Shopkeeper: Heres what I got"
buying(usr)
if(msg == "Sell" && usr.nearshop == 2)
usr<<"Shopkeeper: What you want to sell me?"
selling()
if(msg == "Bye" && usr.nearshop == 2)
usr<<"Shopkeeper: Bye Then"
usr.nearshop = 0

proc/selling(var/obj/O in usr)
set hidden = 0
switch(alert("[src]: Are you sure you want to sell [O] for [O.price] gold?","Selling","Yes","No"))
if("Yes")
usr.gold += O.price
del(O)

How do i get this to work?????


I'm just getting better and better at not using caps =)
proc/selling(var/obj/O in usr)
set hidden = 0
switch(alert("[src]: Are you sure you want to sell [O] for [O.price] gold?","Selling","Yes","No"))
if("Yes")
usr.gold += O.price
del(O)


I'm assuming you have a stat panel for Inventory, is so.


make this small change and try.

proc/selling(var/obj/O in usr.contents)
In response to Tony WK
did that, doesn't work
Don't use usr in procs like that.
In response to Jon88
ok, but it still doesn't work =(
In response to DarkCampainger
I worked on it some more and now it asks if you want to sell, but it goes through all your items asking yes or, how do i get the list to pop up? heres the code:
mob/verb
shopsay(msg as text)
view(6)<<"[usr]:[msg]"
if(msg == "Hi" && usr.nearshop == 1)
usr<<"Shopkeeper: Hi"
usr.nearshop = 2
if(msg == "Buy" && usr.nearshop == 2)
usr<<"Shopkeeper: Heres what I got:"
buying(usr)
if(msg == "Sell" && usr.nearshop == 2)
usr<<"Shopkeeper: What you want to sell me?"
for(var/obj/O in usr)
switch(alert("[src]: Are you sure you want to sell [O] for [O.price] gold?","Selling","Yes","No"))
if("Yes")
usr.gold += O.price
del(O)
return
if(msg == "Bye" && usr.nearshop == 2)
usr<<"Shopkeeper: Bye Then"
usr.nearshop = 0

I know it's beacause of the "for" command but what do i put there instead?