ID:162933
 
umm only demo for this i could find wont let me see the code,
just wondering what stops there money from going to negatives is it a code in the shop keeper or in the mob or both same with max money if he is selling something and will take him to max money? any demos let me know

thanks guys!!!
Im not sure if this is what you meant,but you can try this:
mob/var
max_money=100//write here the maximum money
min_money=0//write here the minimum money
money=50//the starting money
mob/shop_keeper/
max_money=1000//write here the maximum money
min_money=0//write here the minimum money
money=500//the starting money


mob/shop_keeper/verb/Buy()//verb name
set src in view(1)//in which distant from the shop keeper the verb becomes available
if(usr.money>usr.min_money && usr.money<usr.max_money && src.money>src.min_money && src.money<src.max_money){//if usr's and shop keeper's money is between max and min
switch(input("What do you wanna buy?","Buy") in list("banana","Car!!"))//asks user what to buy
if("banana"){
usr<<"Go be a monkey in somewhere else..."
}
if("Car!!"){
if(usr.money-40>=usr.min_money && src.money+40<=src.max_money){//the cost of the car is 40 here
/obj/car =new(usr.contents)
usr.money-=40
src.money+=40
}
else{
usr<<"Can't buy"
}
}
}
else{
usr<<"Can't buy"
}


I writed it in the dm and it worked for me, good luck.
In response to Deyefire275 (#1)
This is what I'm using, working fine for me.
It's from a demo on the site that was pretty straightforward.
mike-



 
turf/ShopKeeper
icon = 'Hrou.dmi'
density=1
var
list/weSell=list()
BuyWhatWeSell=TRUE
sellPricePercentage=50
PearlSalesman
name="Pearl Salesman"
weSell=list(new/obj/scrap)
sellPricePercentage=90
UselessSalesman
name="Useless Salesman"
weSell=list(new/obj/scrap,new/obj/artifact,new/obj/Inventory/Equipment/Weapon/Keyfinder3/Microfinder,new/obj/Inventory/Equipment/Shield/Antique_bullet_proof_vest)
BuyWhatWeSell=FALSE
verb
Buy(obj/O in src.weSell)
set src in oview(1)
set category = "Action"
if(O.stackable)
var/myInput = input("Would you like to buy [O.name] for [O.price] a piece, if so, how many? (0 or less to cancel)")as num
if(myInput<=0)return
if(usr.credits<myInput*O.price)
usr <<"[src.name] tells you, \"You do not have enough money.\""
return
var/obj/youBuy = new O.type
youBuy.amount=myInput
var/obj/object = locate(text2path("[youBuy.type]")) in usr.contents
if(object)
object.addAmount(youBuy.amount)
del(youBuy)
else
usr.contents.Add(youBuy)
usr.credits-=O.price*myInput
else
var/myInput = input("Would you like to buy my [O.name] for [O.price]?")in list("No","Yes")
if(myInput=="Yes")
usr.credits-=O.price
usr.contents.Add(O)
Sell(obj/O in getSellables(usr,BuyWhatWeSell,src.weSell))
set category = "Action"
set src in oview(1)
var/cost=O.price*(src.sellPricePercentage/100)
if(O.stackable)
var/myInput = input("Would you like to sell your [O.name] for [cost] a piece, if so how many would you like to sell? (0 or below to cancel)")as num
if(myInput<=0)return
if(myInput>=O.amount)myInput=O.amount
O.removeAmount(myInput)
var/youGet=myInput*cost
usr.credits+=youGet
else
var/myInput = input("Would you like to sell your [O.name] for [cost]?")in list("No","Yes")
if(myInput=="Yes")
usr.credits+=cost
del(O)

turf/proc/getSellables(mob/Mob,limited,list/onlyTypes)
var/list/list=list()
for(var/obj/O in Mob.contents)
if(limited)
for(var/obj/object in onlyTypes)
if(object.type==O.type)
if(O.tradable)
list+=(O)
break
else
if(O.tradable)list+=(O)
return list
In response to Kichimichi (#2)
Dont mind them there advanced coders >>

mob
Dude
icon = 'NPCs.dmi'//set your icon file name here
icon_state = "Dude"//set the icon state within your icon file
name = "{NPC}Selling Dude"// set the name of your NPC
npc = 1//usr this if you have a teleport or arena system and u dnt want people challening your NPCs or teleing to them.
verb//this sets the verb
Talk()//this is the verbs name
set category = "NPC's"//this set the category witch the verbs are in
set src in oview(2)//how many steps away from the mob you are and still see the verb
switch(input("Want sumtin?", text) in list ("Shirt","Cancel"))//this is the switch input read up on em
if("Shirt")//if the user clicks shirt
if(usr.money>100)//if the users money is more then 40 they can buy it
var/B = new/obj/shirt//gives them the obj
B:loc = usr
usr.money -= 40
usr<<"There you go :D"//sends a message to the user
else//if they dont have enough money
usr<<"Not enough money"//sends message to user
return//just returns the user so the window isnt in his screen >>
if("Cancel")//if they click cancel
return//returns user


mob/var
money=100//how much money they start with




//then make a obj file for shirt



In response to One Piece Entertainment (#3)
on this last example will the money be going to negative
In response to Kylemark (#4)
No it shouldn't since they have it checking if they have enough money and if they don't it sends them a message saying they dont
In response to Kylemark (#4)
mine? No it checks it >>. i edited i forgot to make it so it take away 40$

FIXED

:D


~~~Marcmacman~~~
In response to One Piece Entertainment (#6)
BYOND ROCKS THANKS GUYS, cant wait till i can give some ppl advise :)
In response to Kylemark (#7)
Haha :D just read DM Guides and youll be there!


~~~One Piece Entertainment, Marcmacman~~~