Jump to content
Sign in to follow this  
zuff

[HELP]Dynamic Mission Generator Locality and Dedicated problems

Recommended Posts

I've been working on a dynamic mission and I've run into a few server-sided issues. I've got a good grasp on scripting, but when it comes to what needs to be publicvariable'd, local variabled, server-sided I'm so frustratingly lost.

I've managed to get a dynamic mission script going and it works perfectly fine in singleplayer, but once I threw it up on my client server, nothing worked for anyone except me. At the top of the tasks.sqf script there's a !isServer check which I'm sure is the root of my problems but its from another script I found on the forums and I know random numbers should be generated server side.

What I'm needing is someone to tell me what I need to do to fix this so it works for everyone, even JIP. If you can, tell me if I'm using too many variables, or which variables should be public. Like I said, I'm comfortable with scripting except multiplayer scripting.

Here's my mission folder if anyone wants to take more of a peak at what I have going on:

https://dl.dropbox.com/u/1125473/Arma/%5BSHACK%5DCO30-DYNALAMP.Stratis.7z

It works fine SP and client side server but dedicated is a no go. It's harder to test since I have no dedicated I have regular access to since there

The main snippets of code I'm having issues with:

Init.sqf:

sleep 1;

waitUntil { !isNull player }; // Wait for player to initialize

[] execVM "scripts\tasks\tasks.sqf";

tasks.sqf:

if (!isServer) exitwith {}; // NOTE: in multiplayer, only server should create random numbers.
timeSkip = (paramsArray select 0); // True or False for timeSkip
tasksToComplete = (paramsArray select 1); // Set amount of Tasks to Complete to win mission here
unitsMin = (paramsArray select 2); // Set min amount of units here
unitsMax = (paramsArray select 3); // Set max amount of units here
unitsLeft = (paramsArray select 4); // Units that can be left at objective before being considered completed

vehOn = (paramsArray select 5); // True or False for Enemy Vehicles
vehCount = (paramsArray select 6); // How many vehicles you'd like at each objective
//hint format['timeSkip is %1,tasksToComplete is %2, unitsMin is %3, unitsMax is %4, unitsLeft is %5, vehOn is %6, vehCount is %7',timeSkip, tasksToComplete, unitsMin, unitsMax,unitsLeft, vehOn, vehCount];
//sleep 20;
SideHQ = createCenter east;

taskscompletedcount = 0; 

firstmark = false;
secondmark = false;
thirdmark = false;
fourthmark = false;
fifthmark = false;
sixthmark = false;
sevenththmark = false;

locationPicked = false;
taskNumber = 1;
firsttask = false;

// Pick Location ///////////////////////////////////////////////////////////////////////
while {taskscompletedcount < tasksToComplete} do {

n1 = round ((random tasksToComplete) + 0.5); // generates random number
if (timeSkip == 1) then {
 timeSkipped = round ((random 6) + 6);// generates random number from 6-12
};


if (!firsttask) then
{
   firsttask = true;
   newgroup = createGroup east;
   newTask = player createSimpleTask [format ["Assault Units %1", taskNumber]];
   skipTime (timeSkipped);
   while {!locationPicked} do {
	  m1 = round ((random 6) + 1);
  		if (m1 == 1 && !firstmark) then {
  			locationPicked = true;
  			newTask setSimpleTaskDestination (getMarkerPos "m1");   			
  			createUnits = ["m1","airfield", unitsMin, unitsMax, vehOn, vehCount] execVM "scripts\tasks\createUnits.sqf";
       sleep 5;
  			firstmark = true;
  			secondmark = false;
       thirdmark = false;
       fourthmark = false;
       fifthmark = false;
       sixthmark = false;
       sevenththmark = false;
  		};
  		if (m1 == 2 && !secondmark) then {  
  			locationPicked = true; 			
  			newTask setSimpleTaskDestination (getMarkerPos "m2");   			
  			createUnits = ["m2","agia", unitsMin, unitsMax, vehOn, vehCount] execVM "scripts\tasks\createUnits.sqf";
       sleep 5;
  			firstmark = false;
  			secondmark = true;
		  thirdmark = false;
	  	fourthmark = false;
       fifthmark = false;
       sixthmark = false;
       sevenththmark = false;
  		};
  		if (m1 == 3 && !thirdmark) then {
  			locationPicked = true;			
  			newTask setSimpleTaskDestination (getMarkerPos "m3");		
  			createUnits = ["m3","kamino", unitsMin, unitsMax, vehOn, vehCount] execVM "scripts\tasks\createUnits.sqf";   	
       sleep 5;
  			firstmark = false;
	  	secondmark = false;
	    thirdmark = true;
	    fourthmark = false;
       fifthmark = false;
       sixthmark = false;
       sevenththmark = false;
  		};
  		if (m1 == 4 && !fourthmark) then {
  			locationPicked = true;
  			newTask setSimpleTaskDestination (getMarkerPos "m4");	
  			createUnits = ["m4","mike26", unitsMin, unitsMax, vehOn, vehCount] execVM "scripts\tasks\createUnits.sqf";
       sleep 5;
  			firstmark = false;
		  secondmark = false;
		  thirdmark = false;
       fourthmark = true;
       fifthmark = false;
       sixthmark = false;
       sevenththmark = false;
  		};
     if (m1 == 5 && !fifthmark) then {
       locationPicked = true;
       newTask setSimpleTaskDestination (getMarkerPos "m5");  
       createUnits = ["m5","maxwell", unitsMin, unitsMax, vehOn, vehCount] execVM "scripts\tasks\createUnits.sqf";
       sleep 5;
       firstmark = false;
       secondmark = false;
       thirdmark = false;
       fourthmark = false;
       fifthmark = true;
       sixthmark = false;
       sevenththmark = false;
     };
     if (m1 == 6 && !sixthmark) then {
       locationPicked = true;
       newTask setSimpleTaskDestination (getMarkerPos "m6");  
       createUnits = ["m6","tempest", unitsMin, unitsMax, vehOn, vehCount] execVM "scripts\tasks\createUnits.sqf";
       sleep 5;
       firstmark = false;
       secondmark = false;
       thirdmark = false;
       fourthmark = false;
       fifthmark = false;
       sixthmark = true;
       sevenththmark = false;
     };
     if (m1 == 7 && !seventhmark) then {
       locationPicked = true;
       newTask setSimpleTaskDestination (getMarkerPos "m7");  
       createUnits = ["m7","girna", unitsMin, unitsMax, vehOn, vehCount] execVM "scripts\tasks\createUnits.sqf";
       sleep 5;
       firstmark = false;
       secondmark = false;
       thirdmark = false;
       fourthmark = false;
       fifthmark = false;
       sixthmark = false;
       sevenththmark = true;
     };
   };
       locationPicked = false;
       newTask setTaskState "Assigned";
       player setCurrentTask newTask;
       waitUntil {({alive _x} count units newgroup) == 0 || ({alive _x} count units newgroup) <= unitsLeft};
       deleteGroup newgroup;
       newTask setTaskState "Succeeded";
       hint format["Objective %1 Complete",taskNumber];
       taskNumber = taskNumber + 1;
       taskscompletedcount = taskscompletedcount + 1;
       firsttask = false;
       sleep 5;

 };
};

hint "All done";

createUnits.sqf:

if (!isServer) exitwith {}; // NOTE: in multiplayer, only server should create random numbers.
//hint 'CreateUnits is Working';
_marker = _this select 0;
_patrolMarker = _this select 1;
_unitsMin = _this select 2;
_unitsMax = _this select 3;
_vehOn = _this select 4;
_vehCount = _this select 5;

_unitsDif = 0;
_unitsDif = (_unitsMax - _unitsMin);
_unitsTotal = 0;
_unitsTotal = round ((random _unitsDif) + _unitsMin);
//hint format["Units Total is %1", _unitsTotal];
//hint format["Vehicles are %1", _vehOn];
_counter = 0;
_vehCounter = 0;

while {_counter < _unitsTotal} do {
"O_Soldier_F" createUnit [getMarkerPos _marker, newgroup, "nul =[this, _patrolMarker, ""random"",""nofollow"",""showmarker""] execvm ""scripts\ups.sqf"""];
if (_vehOn == 1) then {
	while {_vehCount > _vehCounter} do {

		_dist = random 45;// this chooses a random distance from 0-45
		_dir = random 360;// this selects a random direction from 360 degrees rotation
		_pos = getMarkerPos _marker;
		_positions = [(_pos select 0) + (sin _dir) * _dist, (_pos select 1) + (cos _dir) * _dist, 0];
		_vehGroup = createGroup east;
		_veh = "O_Galkin_MG_F" createVehicle (_positions);
		_vehDriver = _vehGroup createUnit ["O_Soldier_F", _positions, [], 0, "FORM"];
		_vehGunner = _vehGroup createUnit ["O_Soldier_F", _positions, [], 0, "FORM"];
		_vehDriver assignAsDriver _veh;
		_vehDriver moveInDriver _veh;
		_vehGunner assignAsGunner _veh;
		_vehGunner moveInGunner _veh;
		_veh = nil;
		_vehDriver = nil;
		_vehGunner = nil;
		_vehCounter = _vehCounter + 1;
	};
};
_counter = _counter + 1;
};

I guess my main issue is with variables, but I've tried to reach as much as I can but there doesn't seem to be much covered on the MP side of things.

Thanks guys, you're the best.

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  

×