Jump to content

Recommended Posts

What is _template?  Can you just post all your current code? 

if (isServer || isDedicated) then {
call unitArray;

//No No space
private ["_template","_point","_origin","_totalWaves","_threat","_faction","_doSpawn","_position","_curWave","_Wave"];

//input
_template = _this select 0;
_point = _this select 1;
_origin = _this select 2; 
_totalWaves = _this select 3;

//defines
_threat = 0;
_side = str side _template;
_position = _origin call BIS_fnc_selectRandom;
_curWave = 0;
_Wave = _template;
_totalWaves = _totalWaves - 1;
_armored2 =  (configfile >> "CfgGroups" >> _side >> "OPF_T_F" >> "Armored" >> selectRandom Armored1);
hint _side;

 

	
_spawnVeh = [getPos _position, _side, _armored2] call BIS_fnc_spawnGroup;
//hint str _spawnveh;

//spawn units
//while {_curwave <= _totalWaves && {alive _x} count units _wave <= 1} do {
//	_position = _origin call BIS_fnc_selectRandom;
//	_Wave1 = [getPos _position, _faction, 1] call BIS_fnc_spawnGroup;
//	_Wave1 addWaypoint [position player, 50];
// 	_curWave = _curwave + 1;
//	hint str _curwave;
//	sleep 10;
};


//Handle ending
//while {_curwave >= _totalWaves && {alive _x} count units _wave == 0} do {
//		endmission "END1";
//	};

//};

_template is a unit to get the side and faction.

Share this post


Link to post
Share on other sites

What is "call unitArray" supposed to be? Are you defining your Armored1 etc. variables there? Why does it have to be in a separate function?

Once again, properly naming your variables goes a long way.

In your example _side is not a side, but a string,

leaving _side alone and declaring a new _sideString variable helps keeping the script tidy.

if (isServer || isDedicated) then {
call unitArray;

//No No space
private ["_template","_point","_origin","_totalWaves","_threat","_faction","_doSpawn","_position","_curWave","_Wave"];

//input
_template = _this select 0;//might rename it as _templateUnit since it's supposed to contain an object
_point = _this select 1;
_origin = _this select 2; //this was your array of positions/gamelogics/markers? _positionsArray would be more fitting
_totalWaves = _this select 3;

//defines
_threat = 0;
_side = str side _template; //this is containing a string, not a side, this leads to errors further down the line
_position = _origin call BIS_fnc_selectRandom; //if the selected origin index is a marker/gamelogic/object this will lead to errors in the _spawnVeh line
_curWave = 0;
_Wave = _template;//wait what? I thought _template was a unit? Why do you declare it as _Wave and further down use it to count units _Wave? What?
_totalWaves = _totalWaves - 1;
_armored2 =  (configfile >> "CfgGroups" >> _side >> "OPF_T_F" >> "Armored" >> selectRandom Armored1);
hint _side;

 

	
_spawnVeh = [getPos _position, _side, _armored2] call BIS_fnc_spawnGroup;//This won't work if _position is a marker, also your _side variable is a string which throws up your error posted above
//hint str _spawnveh;

//spawn units
//while {_curwave <= _totalWaves && {alive _x} count units _wave <= 1} do {
//	_position = _origin call BIS_fnc_selectRandom;
//	_Wave1 = [getPos _position, _faction, 1] call BIS_fnc_spawnGroup;
//	_Wave1 addWaypoint [position player, 50];
// 	_curWave = _curwave + 1;
//	hint str _curwave;
//	sleep 10;
};


//Handle ending
//while {_curwave >= _totalWaves && {alive _x} count units _wave == 0} do {
//		endmission "END1";
//	};

//};

_template is a unit to get the side and faction.

Regardless of the data type used I do not get double quotes around EAST.

 

Also, why do you want double quotes around East?

 

Cheers

Share this post


Link to post
Share on other sites

here this code should work. wasnt sure about the arguments (template,point,origin) but this worked for me.

 

 

test.sqf :

if (isServer || isDedicated) then {
_array = call unitArray;


//No No space
private ["_template","_point","_origin","_totalWaves","_threat","_faction","_doSpawn","_position","_curWave","_Wave"];


//input
_template = _this select 0;
_point = _this select 1;
_origin = _this select 2; 
_totalWaves = _this select 3;


//defines
_threat = 0;
_side = side _template;
_sideStr = str _side;
_position = _origin call BIS_fnc_selectRandom;
_curWave = 0;
_Wave = _template;
_totalWaves = _totalWaves - 1;
_armored2 = (configfile >> "CfgGroups" >> _sideStr >> "OPF_T_F" >> "Armored" >> (selectRandom _array));
hint (str _armored2);




_spawnVeh = [getPos _position, _side, _armored2] call BIS_fnc_spawnGroup;
//hint str _spawnveh;


};

unit_array.sqf :

Armored1 = [
"O_T_SPGPlatoon_Scorcher",
"O_T_SPGSection_Scorcher",
"O_T_TankPlatoon",
"O_T_TankPlatoon_AA",
"O_T_TankSection"
];


Armored1

init.sqf :

 

unitArray = Compile preprocessFileLineNumbers  "unit_array.sqf";



[guy,getpos guy,[guy], 2] execVM "test.sqf";

guy is OPFOR man.

Share this post


Link to post
Share on other sites

What is "call unitArray" supposed to be? Are you defining your Armored1 etc. variables there? Why does it have to be in a separate function?

Once again, properly naming your variables goes a long way.

In your example _side is not a side, but a string,

leaving _side alone and declaring a new _sideString variable helps keeping the script tidy.

 

Also, why do you want double quotes around East?

 

Cheers

 

Thank you for the help, I have not been able to get back to my computer for a few days.

What you are looking at it the result of hours of trying different things to get this script working, the naming makes sense to me. I started out counting groups not units which is why I used _template as the first wave, I know I could have done it differently but that's what I did. 

I want the double quotes around EAST because that is what it calls for, manually typing without the quotes would not spawn units when passing a config but it does with a string. I have no Idea why but I am hoping that adding the double quotes will help.  

Share this post


Link to post
Share on other sites

 

here this code should work. wasnt sure about the arguments (template,point,origin) but this worked for me.

 

 

test.sqf :

if (isServer || isDedicated) then {
_array = call unitArray;


//No No space
private ["_template","_point","_origin","_totalWaves","_threat","_faction","_doSpawn","_position","_curWave","_Wave"];


//input
_template = _this select 0;
_point = _this select 1;
_origin = _this select 2; 
_totalWaves = _this select 3;


//defines
_threat = 0;
_side = side _template;
_sideStr = str _side;
_position = _origin call BIS_fnc_selectRandom;
_curWave = 0;
_Wave = _template;
_totalWaves = _totalWaves - 1;
_armored2 = (configfile >> "CfgGroups" >> _sideStr >> "OPF_T_F" >> "Armored" >> (selectRandom _array));
hint (str _armored2);




_spawnVeh = [getPos _position, _side, _armored2] call BIS_fnc_spawnGroup;
//hint str _spawnveh;


};

unit_array.sqf :

Armored1 = [
"O_T_SPGPlatoon_Scorcher",
"O_T_SPGSection_Scorcher",
"O_T_TankPlatoon",
"O_T_TankPlatoon_AA",
"O_T_TankSection"
];


Armored1

init.sqf :

 

unitArray = Compile preprocessFileLineNumbers  "unit_array.sqf";



[guy,getpos guy,[guy], 2] execVM "test.sqf";

guy is OPFOR man.

 

Ok this seems to be working as intended. Thank you.

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

×