Forum Jump :

Author Message


Posts: 5
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2015-06-09 22:48        
     
Essentially I'm working on a RTS game set in Chernarus, and you're leading a revolution, yada yada.
Okay so here's a new one: I've got two variables, MyPop and MyMorale. Mypop is "population," or the amount of people willing to fight for your cause. You expend these points to purchase units, kind of like other simple money scripts you've seen around. MyMorale is the soldiers' willingness to fight and their overall attitude towards you. These are earned by winning battles and completing missions to progress along the storyline. Now I'm trying to get it so that when MyMorale is positive, population points are constantly generated and when negative, population is slowly drained. Here is the script I'm working with, this is all located in the 'init.sqf'
Mymoney = 0;
Mypop = 0;
MyMorale = 1
if (MyMorale < 0) then
{
while {true} do 
{
	Mypop= Mypop - 1;
	sleep 60;
};
} else { 
while {true} do 
{
	Mypop= Mypop + 1;
	sleep 60;
};
All the codes seem to work individually, so I'm pretty sure it's got something to do with the double brackets but I can't seem to get it to work. I'm sure its a simple fix but I'm a scripting n00b so any help is greatly appreciated.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 61
In-game name: Kobayashi Maru

 
#2 Posted at 2015-06-10 02:17        
     
sure!
MyMorale = 1
if (MyMorale < 0) then {...
When your script runs on these lines myMorale = 1 and then... you can't enter the "if" condition.
I guess your loop should start to check myMorale value, so that means your condition inside the while true loop!
Mymoney = 0;
Mypop = 0;
MyMorale = 1

while {true} do {
sleep 60;
if (MyMorale < 0) then {Mypop= Mypop - 1} else { Mypop= Mypop + 1};
};

If you want to limit with a min/max value i.e. say Mypop from -10 to +10 just add after condition:
Mypop = (Mypop min 10) max -10; that means 10 or less, -10 or above

This post was edited by Pierre MGI (2015-06-10 02:26, ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Advertisement


Author Message


Posts: 1525
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2015-06-10 15:36        
     
syntax error MyMorale = 1

try MyMorale = 1; or nothing after it will run.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 61
In-game name: Kobayashi Maru

 
#4 Posted at 2015-06-10 16:27        
     
Yep, well seen

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 5
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#5 Posted at 2015-06-11 00:16        
     
Works, much appreciated guys!