New Problem (Shop Owner Scams Player) in Developer Help
|
|
Code:
mob/NPC/ShopOwner icon = 'npcs.dmi' icon_state = "tat" verb Buy() set src in oview(3) var/clothe = input("What do you wish to buy? 1.Male Black Robe","Buy") as num if (clothe == 1) new/obj/blackrobe(usr) usr << "You got some clothes" usr.Gold -= 13 if (usr.Gold < 13) alert("You can't afford that!", "Buy") return()
|
Problem description:
I don't get an error, however, when I test it, with only 10 gold, the shop owner says "You can't afford that!" and takes away 13 gold anyway (physically impossible, mathematically possible)
|
You are giving the person the item, taking away what it costs THEN check if they actually had enough.
What you want to do is:
- Check the person's choice (using switch() is HIGHLY recommended)
- Check if the person has enough
+ Give item if enough, otherwise deny
Please read the comments I made >_>'