ForumsProgramming ForumCrap, money is going in negatives help

6 2701
staticzone
offline
staticzone
67 posts
Nomad

how do u make it so when you don't have enough money u cant buy an item
heres my code attempt

money = 100
if(money<=0)
money = false;

and the money still keeps going in negatives

  • 6 Replies
HAXALLNOOBS
offline
HAXALLNOOBS
19 posts
Nomad

money = 100
if(money<=0)
money = false;


do...

_root.money = 100
if(_root.money<=0)
_root.money = 0;
awesomeness132
offline
awesomeness132
35 posts
Nomad

or if a item has a certain price.
_root.money = 100;
_root.price = 50;
if(_root.money&ltrice){
item = false;

or something like that.

staticzone
offline
staticzone
67 posts
Nomad

oh ok thx

Green12324
offline
Green12324
4,097 posts
Peasant

if(money<=0)
money = false;


That made me laugh. If you have less then $0 money is false for you. Now you guys are looking at me weird...

*leaves the programming help section*
dank
offline
dank
983 posts
Peasant

In good practice you would create a get/set interface and in there say something like

if(!money<=0)
money += mny;


where mny would be the parameter given by the set function. Or you could just make a global var and function that is called whenever you modify money. It's the same deal, you just don't want to have to change all your money-modifying-scripts whenever you make a small change or have to type it out again and again.
GuardianGames
offline
GuardianGames
25 posts
Nomad

awesomeness132 sounds right but i think its


if(_root.money<=price){

Showing 1-6 of 6