Jump to content
Sign in to follow this  
hogmason

telling the server how many times to run a script

Recommended Posts

ok so i have a task creator script that i what to run so many times only " chosen by params array

my question is how do i tell it to only run so many times

my codes

task creator.sqf

if isserver then 
{

   //Make sure Functions Module is loaded
   waituntil {!isnil "bis_fnc_init"};

   //Time For UPSMON To Prepair Itself
   Sleep 10;

//set up Paramaters
_taskMARKERposition = ["center_positon", false, ["safezone"]] call SHK_pos;	
sleep 0.5;

//create task Marker
_createTASKmarker = createmarker ["taskarea", _taskMARKERposition];
_createTASKmarker setMarkerType "mil_objective";
_createTASKmarker setMarkerColor "ColorRed";
sleep 0.5;

//setup Enemy Airborn Units Patrol Marker
_createREINFORCEMENTSmarker1 = createmarker ["E_Patrol",getMarkerPos "taskarea"];
   _createREINFORCEMENTSmarker1 setmarkershape "ELLIPSE";
   _createREINFORCEMENTSmarker1 setmarkersize [400,400];
   _createREINFORCEMENTSmarker1 setMarkerAlpha 0;

   //setup Enemy Airborn Reinforcements Marker
_createREINFORCEMENTSmarker2 = createmarker ["REIN",getMarkerPos "taskarea"];
   _createREINFORCEMENTSmarker2 setmarkershape "ELLIPSE";
   _createREINFORCEMENTSmarker2 setmarkersize [600,600];
   //_createREINFORCEMENTSmarker2 setMarkerAlpha 0;

//setup Enemy Task Area Chopper Patrol Marker
_createREINFORCEMENTSmarker3 = createmarker ["Task_Choppers",getMarkerPos "taskarea"];
   _createREINFORCEMENTSmarker3 setmarkershape "ELLIPSE";
   _createREINFORCEMENTSmarker3 setmarkersize [1500,1500];
   _createREINFORCEMENTSmarker3 setMarkerAlpha 0;
sleep 10;
//Create Task Targets
  [] spawn Task_Targets;

//Setup Enemy Units
  [] spawn Task_Enemy;
sleep 0.5;	
//setup Enemy Static Units
  [] spawn Task_Static;
sleep 0.5;	
//setup Enemy Chopper Patrol
[] spawn Task_choppers;
sleep 0.5;
//Setup Enemy Airborne Reinforcements
  [] spawn Task_reinforce_Start;
  sleep 10;
  //Setup EAST units Checker
  [] spawn Task_East_chkr;
	sleep 0.5; 

  //setup End Of Task
  waitUntil{(Target1_active ==0) && (Target2_active ==0) && (Enemy_Dead ==1)}; 


  //Setup Task Cleaning
  [] spawn Task_Cleaner;

};


my task starting script

tasksetup.sqf


[] spawn Task_Creator; //calls the precompiled task_creator.sqf

in my params i want

	class Taks Number
       {
	// paramsArray[2]
               title = "How Many Targets";
               values[] = {5,10,20,30,40,50,100};
               texts[] = {"5","10","20","30","40","50","100"};
               default = false;
       };

i hope some one can help but im pretty sure its going to be tought.

Cheers

Share this post


Link to post
Share on other sites

for "_x" from 1 to (paramsArray select 2) do {[] spawn Task_Creator;};

I'm assuming here class Taks Number is the third parameter. If it's the second, just replace paramsArray select 2 by paramsArray select 1.

Share this post


Link to post
Share on other sites

Erm. And you wanna use call instead of spawn here:

for "_x" from 1 to (paramsArray select 2) do {[] call Task_Creator;};

Otherwise your function's gonna run multiple times in parallel. (i guess you want the whole thing to restart say 5 times, not to have the 5 objectives set up from the start, from what i gathered from our other discussion).

Share this post


Link to post
Share on other sites

this is how i done it mate

if isserver then

{

for "_x" from 1 to (paramsArray select 3) do {[] spawn Task_Creator;};

};

the paramater in my description is number 4 params array 3

---------- Post added at 22:51 ---------- Previous post was at 22:50 ----------

rgr m8 changing to call ;)

Share this post


Link to post
Share on other sites

SO THIS WORKS GREAT

if isserver then

{

for "_x" from 1 to (paramsArray select 3) do {[] call Task_Creator;};

};

////////////////////

BUT it spawns fine the first task then the task after that it creates 2 the the 3rd task it creates everything 3 times.

Share this post


Link to post
Share on other sites

Also mate how can i tie this in after the selecte amount of times to run the script has finnished. so i can end the mission

hint "Map complete";

sleep 5;

endMission "END1";

Share this post


Link to post
Share on other sites

I have no idea where that issue is coming from, but it's probably an issue in all your spawned code, some stuff might not be correctly reinitialized. Can't say for sure.

For the end code, you just have to add it right after the for loop. Once it's completed, it will end the mission.

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  

×