ID:160649
 
Ok so Im making a market system in my game where players can make stuff with their job and then sell it to other players. I have it set up where they put the item up on the market at a certain price. And then all other players can view it.

What I cant figure out how to do is display all items on the market to a buyer and allow them to choose an item. I was thinking of making a pop up grid and that would display all the information, but not sure how to do the verb so they can only see the buy verb when looking at this grid.
Make it so theres a wall/desk/something with density blocking the buyers from the obj
obj/Fine_Jewelery
icon='Fine.dmi'
icon_state="Jewelery"
var/sellprice=2000
var/owner
var/forsale
verb/ForSale()
if(src.forsale==1)
src.forsale=0
usr << "[src] is no longer for sale!"
else
src.forsale=1
usr << "[src] is for sale!"

verb/Buy()
set src in oview(2)//if you put it behind glass, they can pick it up
if(src.forsale==1)
switch(alert("Would you like to buy [src]","Purchase?","No","Yes"))
if("Yes")
usr.contents += new/obj/Fine_Jewelery
usr.gold -= src.sellprice
src.owner= "[usr.name]"
del src
else
usr << "This [src] is not for sale!"
return

verb/Get()
set src in oview(1)
if(src.owner==null)
src.Move(usr)
src.forsale=0
owner= "[usr.name]"
view() << "[src] belongs to [usr]"
if(src.owner==usr.name)
src.forsale=0
src.Move(usr)
view() <<"[usr] got their [src]"
else
src.forsale=0
src.Move(usr)
view()<<"[usr] picked up [owner]'s [src]"
src.owner= "[usr.name]"
In response to Quiet Screams
Actually that isnt exactly what I was refering too. They arent gonna be anywhere near the actual object they are just gonna see a list of items and select what they want to buy.

But i figured out a way, i used the click command and added it to a grid so when they click on it in the grid it ask them if they want to buy it. But thanks for the input
In response to NightJumper88
Also remember that checking boolean vars (true or false) is better than using ==1 or ==0/null/"".
In response to NightJumper88
Alright. I hope i helped a little xD I'll use that code for my game.
Something like this could work:

mob/verb
show_market_window()
if(!client) return
winshow(src, "myMarketWindow")
verbs += new/mob/verb/buy //window is visible, so show the verb
verbs += new/mob/verb/hide_market_window
verbs -= /mob/verb/show_market_window
hide_market_window()
if(!client) return
winshow(src, "myMarketWindow", 0)
verbs -= /mob/verb/buy
verbs += new/mob/verb/show_market_window
verbs -= /mob/verb/hide_market_window
buy()
if(winget(src, "myMarketWindow.is-visible") != "true") verbs -= /mob/verb/buy //hide the verb if the window has been closed
...

mob
//hide the verb
New()
. = ..()
verbs -= /mob/verb/buy
verbs -= /mob/verb/hide_market_window
Logout()
verbs -= /mob/verb/buy
verbs -= /mob/verb/hide_market_window
return ..()


Only add the verb if the player is viewing the window. You could also prevent players from closing the window by disabling it in the interface and making your own close button, which calls hide-market-window.
In response to Android Data
Can't the window be closed by ALT-F4, regardless, though?