Jump to content
Sign in to follow this  
ryansoper

Variables in if statement in seperate .sqf?

Recommended Posts

Hi guys, in my init file i have this:

player1 setVariable ["money", 10000];
player2 setVariable ["money", 10000];

then in a seperate file 'rentTruck.sqf' I have:

if ("money" < 950) then
{
   player groupChat "You do not have enough Money!";
} else {
   player setVariable ["money", -950];
   player groupChat "Vehicle Rented!";
};

The code in the rental file doesn't seem to run at all, i can only assume it can't access the variable? So it does a kind of condition (nil) thing? Any Ideas?

Share this post


Link to post
Share on other sites
_money = player getVariable ["money", 0];
if (_money < 950) then {
   player groupChat "You do not have enough Money!";
} else {
   player setVariable ["money", _money - 950];
   player groupChat "Vehicle Rented!";
};

Share this post


Link to post
Share on other sites

SaMatra, Second time you have helped me now!

Thanks! Might have to pop onto your wasteland server at some point ;)

Share this post


Link to post
Share on other sites

May be easier to have a function for handling your money btw ;)

FNC_AddMoney =
{
private["_money"];
_money = _this select 0;
player setVariable ["money", player getVariable "money" + _money];
};

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×