Jump to content

Recommended Posts

Hi all:

I have been doing missions where always in the initServer.sqf I do conditionals for missions in the following way:

 

initServer.sqf

private _run = true;

private _files = datosInfo; // files
private _doc_adquirido = true; //notifications documents adquires
objetivoSecundario = 0;
publicVariable "objetivoSecundario";

//Markers
_mrk1 = createMarker ["mrk1", icon1]; //Creation Marker
_mrk2 = createMarker ["mrk2", icon2]; //Creation Marker
_mrk3 = createMarker ["mrk3", icon3]; //Creation Marker
_mrk4 = createMarker ["mrk4", icon4]; //Creation Marker

while {_run} do {

	//Mision One
	if (!alive _files && _doc_adquirido ) then {
		
      	objetivoSecundario = objetivoSecundario + 8;
		publicVariable "objetivoSecundario";
		
      	["objSecond", ["Members Add 8 PTS!"]] remoteExecCall ["BIS_fnc_showNotification"];
		
		//Markers
		_mrk1 setMarkerShape "ICON"; 
		_mrk1 setMarkerType "mil_unknown";
		"mrk1" setMarkerColor "ColorWEST";
		//"mrk1" setMarkerText "Conseguir Archivos.";

		_mrk2 setMarkerShape "ICON"; 
		_mrk2 setMarkerType "mil_unknown";
		"mrk2" setMarkerColor "ColorWEST";
		//"mrk2" setMarkerText "Conseguir Archivos.";

		_mrk3 setMarkerShape "ICON"; 
		_mrk3 setMarkerType "mil_unknown";
		"mrk3" setMarkerColor "ColorWEST";
		//"mrk3" setMarkerText "Conseguir Archivos.";

		_mrk4 setMarkerShape "ICON"; 
		_mrk4 setMarkerType "mil_unknown";
		"mrk4" setMarkerColor "ColorWEST";
		//"mrk4" setMarkerText "Conseguir Archivos.";

		_doc_adquirido = false;

	}; //END MISSION CONDITIONAL.
  
}; //END WHILE

 

But now I realize that in a bad way I'm doing it wrong, because the server will stay working only that conditional, leaving aside any process that is part of this, since additional scripts for the server do not work for me when I use the while and until the process finishes, but is there another way to execute a conditional when it is fulfilled in initServer.sqf without using while? to make the server continue to work on other scripts and not make a practically infinite loop?

Share this post


Link to post
Share on other sites

Would this be fine in this way?

 


private _files = datosInfo; // files

objetivoSecundario = 0;
publicVariable "objetivoSecundario";

//Markers
_mrk1 = createMarker ["mrk1", icon1]; //Creation Marker
_mrk2 = createMarker ["mrk2", icon2]; //Creation Marker
_mrk3 = createMarker ["mrk3", icon3]; //Creation Marker
_mrk4 = createMarker ["mrk4", icon4]; //Creation Marker

//Mision One
_files addEventHandler ["Deleted", {
	
		objetivoSecundario = objetivoSecundario + 8;
		publicVariable "objetivoSecundario";
		
      	["objSecond", ["Members Add 8 PTS!"]] remoteExecCall ["BIS_fnc_showNotification"];
		
		//Markers
		_mrk1 setMarkerShape "ICON"; 
		_mrk1 setMarkerType "mil_unknown";
		"mrk1" setMarkerColor "ColorWEST";
		//"mrk1" setMarkerText "Conseguir Archivos.";

		_mrk2 setMarkerShape "ICON"; 
		_mrk2 setMarkerType "mil_unknown";
		"mrk2" setMarkerColor "ColorWEST";
		//"mrk2" setMarkerText "Conseguir Archivos.";

		_mrk3 setMarkerShape "ICON"; 
		_mrk3 setMarkerType "mil_unknown";
		"mrk3" setMarkerColor "ColorWEST";
		//"mrk3" setMarkerText "Conseguir Archivos.";

		_mrk4 setMarkerShape "ICON"; 
		_mrk4 setMarkerType "mil_unknown";
		"mrk4" setMarkerColor "ColorWEST";
		//"mrk4" setMarkerText "Conseguir Archivos.";

}];
	
	

Using events like this would be better on the server?

 

Share this post


Link to post
Share on other sites
19 hours ago, pierremgi said:

What for?????

Appropriate method to create mission conditionals, if an action is fulfilled the objective is fulfilled and I wanted to know if I'm doing it properly,

 

Sorry my bad english

Share this post


Link to post
Share on other sites

Ah.... sure, If you delete _files, so dataInfos, which comes from nowhere but probably your editor, but why not?

 

Your first version, the while loop, is OK if you spawn it (then run aside):

 

[] spawn {

  while {yourCondition} do {

   < what you want code>

   sleep <sometime> // according to the need of the refreshing cadence (from 0.01 for something looking each frame to 2 or even 5 seconds for applying code with no hurry)

  };

};

 

NB: Think about what could make yourCondition false also.

 if you can use an EH, it's fine. Not ever possible. Use but not abuse of EH onEachFrame for nuts.

  • Thanks 1

Share this post


Link to post
Share on other sites
2 minutes ago, pierremgi said:

Ah.... sure, If you delete _files, so dataInfos, which comes from nowhere but probably your editor, but why not?

 

Your first version, the while loop, is OK if you spawn it (then run aside):

 

[] spawn {

  while {yourCondition} do {

   < what you want code>

   sleep <sometime> // according to the need of the refreshing cadence (from 0.01 for something looking each frame to 2 or even 5 seconds for applying code with no hurry)

  };

};

 

NB: Think about what could make yourCondition false also.

 if you can use an EH, it's fine. Not ever possible. Use but not abuse of EH onEachFrame for nuts.

 

Thanks for the help man, and thanks for the indication of the EH

ddMissionEventHandler ["EntityKilled",
{
	params ["_killed", "_killer", "_instigator"];
	if (isNull _instigator) then {_instigator = UAVControl vehicle _killer select 0}; // UAV/UGV player operated road kill
	if (isNull _instigator) then {_instigator = _killer}; // player driven vehicle road kill
	//_westSide    = [objNull, true] call BIS_fnc_objectSide;
	if (side group _killed == WEST) then {[1,11] call FAM_fnc_puntaje};


}];

 

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

×