ID:142970
 
Code:
obj
var/Purchased
var/Worth
Sword
icon = 'Icons.dmi'
icon_state = "sword"
Worth = 10
Dagger
icon = 'Icons.dmi'
icon_state = "dagger"
Worth = 5

Staff
icon = 'Icons.dmi'
icon_state = "staff"
Worth = 15
DblClick()
src.Move(usr)
mob
var/Crowns = 5
var/Chatting
verb
Say(txt as text)
view() << "[usr] says: [txt]"
for(var/mob/Bob/n in view(2))
if(!Chatting)
n.ScanMessage(txt,n)

Bob
icon = 'Icons.dmi'
icon_state = "NPC"
DblClick()
Shopping_Proc()

mob/proc
ScanMessage(var/n,var/npc)
if(Chatting) return
if(findtext("[n]","Hello"))
sleep(5)
view() << "[npc] says: Hello to you, [usr]!"
if(findtext("[n]","Buy"))
src.Shopping_Proc("Buy")
Chatting = 1
return
if(findtext("[n]","Purchase"))
src.Shopping_Proc("Purchase")
Chatting = 1
return
if(findtext("[n]","Sell"))
for(var/obj/i in usr.contents)
if(findtext("[n]","[i]"))
src.Shopping_Proc("Sell","[i]")
Chatting = 1
return
Shopping_Proc(var/n,var/s)
if(n=="Buy" || n=="Purchase")
//Scan inv. for unpurchased items..
sleep(5)
view() << "[src] says: Are you sure you want to buy these?"
if(n=="Sell" && s)
sleep(5)
view() << "[src] says: Are you sure to sell your [s]?"


Problem description:
The code works quite well, and does everything I need it to. Though once I enter the Shopping_Proc() I need a second input from the user, a yes or no. But I'm not sure how to let the proc see the users' text without calling another proc. ((Yes I know "Buy" isn't completed, I haven't started coding it yet.))
You need to stop using usr in all those procs. view() should be view(src). usr needs to be replaced by an argument passed to the proc.

In order to do what you want, you're going to have to store the last person who talked to the NPC, and whatever the last interaction was (which would mean storing a variable containing WHAT it was and storing a variable containing the interaction). On top of that, you'd probably want to store world.time so that you can ignore a "yes" made an hour later. Once you've got all that data stored, you just have to make the shopkeeper respond to "yes" or "no".

Really, though, this is incredibly complicated for little benefit.