ID:1769821
 
Keywords: stacking, verb
Code:


I don't have a specific code in mind at the moment, but how would I try to make it to where if you were to click the "sell" verb or the "sell" button from the npc to make it not spammable to make it go past the first time? For instance, if you were to click sell once, you can see the list of items you can sell. If you click sell again, it stacks the list to where you can sell more than once of the same item. How do I stop this?:

By setting an if statement check on it.

mob/player/var/purchasing = 0

mob/npc/shopkeepers
var/list/inventoryList

General_Store
inventoryList = list("Hat" = 4, "Cat" = 5, "Bat" = 2, "Mat" = 0)

verb/Sell()
if(istype(usr, /mob/player))
var/mob/player/p = usr
if(!p.purchasing) //*Check if they're already purchasing.
p.purchasing = 1 //Stop them from clicking the purchase verb.
var/purchase

do { //Do this...
purchase = input("What would you like to buy?") as null | anything in src.inventoryList

if(purchase == 0)
alert(usr, "Sorry! We're all sold out of that.")
else
//give them the purchased item here
break
} while(purchase) //*while purchase...
p.purchasing = 0 //Let them click the purchase verb again.

//The do while loop is just so you can constantly loop through of the items aren't in stock. If they click "Cancel", purchase will become null and your script will end.


In short, all I did was give the player a variable named purchasing and set it to 1 when they purchase. If it's set to one, don't let them buy anything from the NPC.