mob
NPC
MartK
name = "Mart Keeper"
icon = 'Mart keeper.dmi'
icon_state = "1"
NPC = 2
verb
Buy()
set src in oview(2)
set category = "NPC"
switch(input("Welcome to my mart,what would you like to buy?") in list ("Pokeball : 75","Potion : 100","Super Potion : 200"))
if("Pokeball : 75")
var/buy = input("How many Pokeballs do you wish to buy?")as num
var/buying = buy*75
for(var/obj/Pokemoney/O in usr.contents)
if(buying <= 0)
usr<<"You can't buy that ammount"
return
if(buying > O.ammount)
usr<<"You don't have enough money for that"
return
else
usr<<"You have bought [buy] Pokeball(s)"
O.ammount -= buying
var/obj/Pokeball/B = new/obj/Pokeball
B.ammount = buy
for(var/obj/Pokeball/A in usr.contents)
counter+=1
if(counter<=0)
B.Move(usr)
B.name = "Pokeball"
B.name= "[B.name]: [B.ammount]"
else
for(var/obj/Pokeball/A in usr.contents)
A.ammount+=B.ammount
A.name = "Pokeball"
A.name= "[A.name]: [A.ammount]"
del(B)
O.name = "Pokemoney"
O.name= "[O.name]: [O.ammount]"
if("Potion : 100")
var/buy = input("How many Potions do you wish to buy?")as num
var/buying = buy*100
for(var/obj/Pokemoney/O in usr.contents)
if(buying <= 0)
usr<<"You can't buy that ammount"
return
if(buying > O.ammount)
usr<<"You don't have enough money for that"
return
else
usr<<"You have bought [buy] Potion(s)"
O.ammount -= buying
var/obj/Potion/B = new/obj/Potion
B.ammount = buy
for(var/obj/Potion/A in usr.contents)
counter+=1
if(counter<=0)
B.Move(usr)
B.name = "Potion"
B.name= "[B.name]: [B.ammount]"
else
for(var/obj/Potion/A in usr.contents)
A.ammount+=B.ammount
A.name = "Potion"
A.name= "[A.name]: [A.ammount]"
del(B)
O.name = "Pokemoney"
O.name= "[O.name]: [O.ammount]"
if("Super Potion : 200")
var/buy = input("How many Super Potions do you wish to buy?")as num
var/buying = buy*200
for(var/obj/Pokemoney/O in usr.contents)
if(buying <= 0)
usr<<"You can't buy that ammount"
return
if(buying > O.ammount)
usr<<"You don't have enough money for that"
return
else
usr<<"You have bought [buy] Super Potion(s)"
O.ammount -= buying
var/obj/SPotion/B = new/obj/SPotion
B.ammount = buy
for(var/obj/SPotion/A in usr.contents)
counter+=1
if(counter<=0)
B.Move(usr)
B.name = "Super Potion"
B.name= "[B.name]: [B.ammount]"
else
for(var/obj/SPotion/A in usr.contents)
A.ammount+=B.ammount
A.name = "Super Potion"
A.name= "[A.name]: [A.ammount]"
del(B)
O.name = "Pokemoney"
O.name= "[O.name]: [O.ammount]"
Problem description:Mostly when there are many people online the NPC won't sell them the item but he still takes money from them
Also: that entire thing is a gigantic mess. You've mucked up the concept of item stacking and are obviously paying the price for it. You've also created a mess of buying items. This is what would make more sense:
(the indentation is mixed up because I wrote one in the IDE and one on the forum)
Anyway, that gives you items which will stack without you having to do anything at all besides call Move(), and a generic shopkeeper that can sell anything by simply dropping items at their feet in the map editor.