ID:149048
 
My shopkeeper for my game doesn't work. Whenever you buy or sell an item the gold doesn't change. please help me. If you need to see the code tell me and I'll post it here.
They're going to need to see the snippet of DM, or else they can't help you. So, post it. It's probably a little error or something.
In response to Mertek
mob
var
Gold

Login()
world<<"[usr] joins!"
usr.loc = locate(1,1,1)
usr.Gold = 50
Logout()
world<<"[usr] leaves!"
del(src)
Stat()
statpanel("Gold")
stat("Gold","$[usr.Gold]")
statpanel("Inventory",usr.contents)
obj
var
price
Clothing
price = 25
Dagger
price = 25
ShortSword
price = 100
mob
Merchant
icon = 'Merchant.dmi'
verb
Sell(obj/O in usr.contents)
set src in oview(1)
switch(input("Are you sure you want to sell the [O] for [O.price]?")in list("Yes","No"))
if("Yes")
usr.Gold += O.price
usr<<" You sold a [O] for [O.price]!"
del(O)
if("No")
usr<<"You didn't sell a [O]"
Buy()
set src in oview(1)
switch(input("How may I help you?")in list("Clothing - 25","Dagger - 25","Short Sword - 100"))
if("Clothing - 25")
if(usr.Gold >= 25)
usr<<"you bought Clothing"
usr.Gold -= 25
new/obj/Clothing(usr)
else
usr<<"Not enough Gold!"
if("Dagger - 25")
if(usr.Gold >= 25)
usr<<"You bought a Dagger"
usr.Gold -= 125
new/obj/Dagger(usr)
else
usr<<"Not enough Gold!"
if("Short Sword - 100")
if(usr.Gold >= 100)
usr<<"You bought a Short Sword"
usr.Gold -= 100
new/obj/ShortSword(usr)
else
usr<<"Not enough Gold!"
turf
icon = 'turfs.dmi'
world
In response to Codesterz
That works fine. It subtracts gold when you buy things...Nothing wrong. You might want to change the amount it takes away with the dagger to 25 though.
I found the problem. In another coding File a different gold was being used!

Thanks anyway