It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Flash Forum

Need some help with shop

Moderator: Phate

Need some help with shop

Postby xDabombx on Wed Jan 23, 2008 1:10 am

ok i have the basic idea for how to code a shop. for instince in my game i make it so when you kill someone you get +5 points(money) and i have a shop that if something costs $10 it would subtract 5 points, but i need help on making it so that you cant buy something you have enough money for, so it dosnt go into the negatives. any help at all would be greatly apreciated
xDabombx
 
Posts: 20
Joined: Wed Jan 02, 2008 8:11 am

Postby tkgd2007 on Sun Feb 10, 2008 11:37 am

moneyvar is the amount of money you have in your wallet and amount is the amount of money the object you are trying to purchase.
The following code checks to make sure that you won't go into negative money by purchasing something.
Code: Select all
if (moneyvar - amount >= 0){
    //do something
}


You could also add an error message saying you don't have enough money
Code: Select all
else{
//error message or sound or whatever
}
tkgd2007
100+ Club
 
Posts: 103
Joined: Thu Nov 15, 2007 10:46 pm


Who is online

Users browsing this forum: No registered users and 0 guests