ID:268656
 
mob/NPC/Shopkeeper
icon = 'Character Icons.dmi'
icon_state = "Shopkeeper"
density = 1
var/TagSave = 1
New()
for(var/obj/items/A)
contents += new A
Click()
if(src in oview(4))
switch(alert("Hello! Welcome to our shop, would you like to buy anything?","Shopkeeper","Buy","Sell","Leave"))
if("Buy")
var/obj/R = input(usr,"What would you like to buy?")in src.contents
switch(alert("Will you buy [R.name] for [R.price]?","Shopkeeper","Yes","No"))
if("Yes")
if(R.price == null)return
if(usr.G >= R.price)
usr.G -= R.price
usr<<"You have obtained [R]!"
new R(usr.contents)
else
usr<<"You do not have enough G for this."
if("Sell")
if(usr.contents==list())
usr<<"{NPC}[src] says: You have nothing to sell!"
return
var/obj/items/R = input(usr,"What would you like to buy?")in src.contents
if(R.name == "Cancel")
return
if(R.equipped == 1)
return
if(R.price == null)return
var/SellingPrice = R.price/2
switch(alert("Will you sell [R.name] for [SellingPrice]?","Shopkeeper","Yes","No"))
if("Yes")
usr.G += SellingPrice
R.loc=src
usr<<"You have sold [R]!"
how do i make it so when i sell the item to npc it delete from my inventory?
Excellent post.
In response to DeathAwaitsU
Had to edit it
Vash_616 wrote:
> mob/NPC/Shopkeeper
> icon = 'Character Icons.dmi'
> icon_state = "Shopkeeper"
> density = 1
> var/TagSave = 1
> Click()
> if(src in oview(4))
> switch(alert("Hello! Welcome to our shop, would you like to buy anything?","Shopkeeper","Buy","Sell","Leave"))
> if("Buy")
> if(src.contents==list())
> usr<<"{NPC}<font color = blue><b>[src] says: I have nothing to sell right now."
> return
> var/obj/R = input("What would you like to buy?")in src.contents
> if(R.name == "Cancel")
> return
> switch(alert("Will you buy it for [R.price]?","Shopkeeper","Yes","No"))
> if("Yes")
> if(usr.G >= R.price)
> usr.G -= R.price
> usr<<"You have obtained [R]!"
> R.loc=usr
> SaveItems()
> else
> usr<<"You do not have enough G for this."
> if("Sell")
> if(usr.contents==list())
> usr<<"{NPC}<font color = blue><b>[src] says: You have nothing to sell!"
> return
> var/obj/R = input("What would you like to sell?")in usr.contents
> if(R.name == "Cancel")
> return
> if(R.equipped == 1)
> return
> var/SellingPrice = R.price/2
> switch(alert("Will you sell it for [SellingPrice]?","Shopkeeper","Yes","No"))
> if("Yes")
> usr.G += SellingPrice
> R.loc=src
> usr<<"You have sold [R]!"
> SaveItems()
>

I Want it su wen i goto sell item and i have no item he sais

usr<<"{NPC}<font color = blue>[src] says: You have nothing to sell!"

But he dont do that,help pls

Just a guess, but try putting:
if(usr.contents==null
instead of
if(usr.contents==list())

propably wont work, but worth a try.

Also, how come the spelling in your code is good but the spelling in you posts is terrible?
I'm not sure what you're doing there but i think del(R) should work.
In response to Smoko
Spelling is bad cus i am learning from a demo and i want to test sumthing.
In response to Vash_616
Vash_616 wrote:
Spelling is bad cus i am learning from a demo and i want to test sumthing.

wtf? Learning from a demo makes your spelling bad?