Jump to content
Sign in to follow this  
1para{god-father}

Script help on Variables and Case

Recommended Posts

OK having an issue and not sure why? The script spawns in fine (it is just a test so it spawn in the same for now) but it will not assign the Task to the Group ?

If i place the Task right after the spawn as below it all works fine , it is like the _grpP does not exist in the 2nd case ,is it something to do with the variable ? do i need to declare it so the 2nd case can use it ?

I know it is getting there as i get the Hint

works

	case 0: {
		closeDialog 0;
		sZoneLocal = createMarker ["sZoneLocal", [(position player select 0), (position player select 1) +1500 , 0]];
		sZoneLocal setMarkerBrushLocal "SOLID";
		sZoneLocal setMarkerShapeLocal "ELLIPSE";
		sZoneLocal setMarkerColorLocal "ColorGreen";
		sZoneLocal setMarkerDirLocal 0;
		sZoneLocal setMarkerSizeLocal [20,20];
		click = 0;
		_cpPos = markerPos "sZoneLocal";
		hint 'click on Map for Enemy Spawn Point';
		onMapSingleClick "sZoneLocal setMarkerPosLocal _pos; click = 1";
		waitUntil {click == 1};
		HINT "";
		sleep 5;
		_grpP = [getmarkerpos "sZoneLocal", EAST, (configFile >> "CfgGroups" >> "EAST" >> "BIS_TK_INS" >> "Infantry" >> "TK_INS_Group")] call BIS_fnc_spawnGroup;

/////add task/////////
[color="#FF0000"][_grpP, _cpPos, 300, 7, "MOVE", "SAFE", "YELLOW", "NORMAL", "STAG COLUMN", "_grpP spawn CBA_fnc_searchNearby", [5+(random 5),10+(random 5),15+(random 5)]] call CBA_fnc_taskPatrol;[/color]

This spawns but will not give the _grpP the task ?

if (_sgroup >= 0) then {
switch (_selectedgroup) do {
////INF
	case 0: {
		closeDialog 0;
		sZoneLocal = createMarker ["sZoneLocal", [(position player select 0), (position player select 1) +1500 , 0]];
		sZoneLocal setMarkerBrushLocal "SOLID";
		sZoneLocal setMarkerShapeLocal "ELLIPSE";
		sZoneLocal setMarkerColorLocal "ColorGreen";
		sZoneLocal setMarkerDirLocal 0;
		sZoneLocal setMarkerSizeLocal [20,20];
		click = 0;
		_cpPos = markerPos "sZoneLocal";
		hint 'click on Map for Enemy Spawn Point';
		onMapSingleClick "sZoneLocal setMarkerPosLocal _pos; click = 1";
		waitUntil {click == 1};
		HINT "";
		sleep 5;
		_grpP = [getmarkerpos "sZoneLocal", EAST, (configFile >> "CfgGroups" >> "EAST" >> "BIS_TK_INS" >> "Infantry" >> "TK_INS_Group")] call BIS_fnc_spawnGroup;

	};
///Tek
	case 1: {
	closeDialog 0;
	sZoneLocal = createMarker ["sZoneLocal", [(position player select 0), (position player select 1) +1500 , 0]];
	sZoneLocal setMarkerBrushLocal "SOLID";
	sZoneLocal setMarkerShapeLocal "ELLIPSE";
	sZoneLocal setMarkerColorLocal "ColorGreen";
	sZoneLocal setMarkerDirLocal 0;
	sZoneLocal setMarkerSizeLocal [20,20];
	click = 0;
	_cpPos = markerPos "sZoneLocal";
	hint 'click on Map for Enemy Spawn Point';
	onMapSingleClick "sZoneLocal setMarkerPosLocal _pos; click = 1";
	waitUntil {click == 1};
	HINT "";
	sleep 5;
	_grpP = [getmarkerpos "sZoneLocal", EAST, (configFile >> "CfgGroups" >> "EAST" >> "BIS_TK_INS" >> "Infantry" >> "TK_INS_Group")] call BIS_fnc_spawnGroup;

	};
//ARMOUR
	case 2: {
	closeDialog 0;
	sZoneLocal = createMarker ["sZoneLocal", [(position player select 0), (position player select 1) +1500 , 0]];
	sZoneLocal setMarkerBrushLocal "SOLID";
	sZoneLocal setMarkerShapeLocal "ELLIPSE";
	sZoneLocal setMarkerColorLocal "ColorGreen";
	sZoneLocal setMarkerDirLocal 0;
	sZoneLocal setMarkerSizeLocal [20,20];
	click = 0;
	_cpPos = markerPos "sZoneLocal";
	hint 'click on Map for Enemy Spawn Point';
	onMapSingleClick "sZoneLocal setMarkerPosLocal _pos; click = 1";
	waitUntil {click == 1};
	HINT "";
	sleep 5;
	_grpP = [getmarkerpos "sZoneLocal", EAST, (configFile >> "CfgGroups" >> "EAST" >> "BIS_TK_INS" >> "Infantry" >> "TK_INS_Group")] call BIS_fnc_spawnGroup;

	};
/////AIR	
	case 3: {
		closeDialog 0;
		sZoneLocal = createMarker ["sZoneLocal", [(position player select 0), (position player select 1) +1500 , 0]];
		sZoneLocal setMarkerBrushLocal "SOLID";
		sZoneLocal setMarkerShapeLocal "ELLIPSE";
		sZoneLocal setMarkerColorLocal "ColorGreen";
		sZoneLocal setMarkerDirLocal 0;
		sZoneLocal setMarkerSizeLocal [20,20];
		_cpPos = markerPos "sZoneLocal";
		click = 0;
		hint 'click on Map for Enemy Spawn Point';
		onMapSingleClick "sZoneLocal setMarkerPosLocal _pos; click = 1";
		waitUntil {click == 1};
		HINT "";
		sleep 5;
		_grpP = [getmarkerpos "sZoneLocal", EAST, (configFile >> "CfgGroups" >> "EAST" >> "BIS_TK_INS" >> "Infantry" >> "TK_INS_Group")] call BIS_fnc_spawnGroup;

	};
//INF & TEK	
	case 4: {
		closeDialog 0;
		sZoneLocal = createMarker ["sZoneLocal", [(position player select 0), (position player select 1) +1500 , 0]];
		sZoneLocal setMarkerBrushLocal "SOLID";
		sZoneLocal setMarkerShapeLocal "ELLIPSE";
		sZoneLocal setMarkerColorLocal "ColorGreen";
		sZoneLocal setMarkerDirLocal 0;
		sZoneLocal setMarkerSizeLocal [20,20];
		click = 0;
		_cpPos = markerPos "sZoneLocal";
		hint 'click on Map for Enemy Spawn Point';
		onMapSingleClick "sZoneLocal setMarkerPosLocal _pos; click = 1";
		waitUntil {click == 1};
		HINT "";
		sleep 5;
		_grpP = [getmarkerpos "sZoneLocal", EAST, (configFile >> "CfgGroups" >> "EAST" >> "BIS_TK_INS" >> "Infantry" >> "TK_INS_Group")] call BIS_fnc_spawnGroup;


	};

};

};

[color="#FF0000"]///////////////////////////NOW DO THE TASK /This get there but does not add the task ////////////////////////////////////////////////[/color]
if (_stask >= 0) then {
switch (_selectedtask) do {

	case "Patrol": {[_grpP, _cpPos, 300, 7, "MOVE", "SAFE", "YELLOW", "NORMAL", "STAG COLUMN", "_grpP spawn CBA_fnc_searchNearby", [5+(random 5),10+(random 5),15+(random 5)]] call CBA_fnc_taskPatrol;};
hint format ["Task Type: %1", _selectedtask];
	case "Defend": {[_grpP, _cpPos, 200] call CBA_fnc_taskdefend;};
	case "Building": {_grpP execvm "PlaceInBuilding.sqf";};
	case "Attack": {[_grpP,300,70,"SAD", "AWARE", "RED","Normal","LINE", "_grp spawn CBA_fnc_searchNearby"] call CBA_fnc_addWaypoint;};
	case "Hunt": {
		while {{alive _x} count (units _grpP)  >= 1} do { 
 				_pos = _hunted call CBA_fnc_getpos;
			[_grpP,_pos,50,"SAD", "AWARE", "RED","FULL","COLUMN", "_grp spawn CBA_fnc_searchNearby"] call CBA_fnc_addWaypoint;
			sleep 30 + (random 15);
   				deleteWaypoint  [_grpP, 0];
   				deleteMarkerLocal sZoneLocal;
			 };
		};
	};
};
sleep 5;
Deletemarker "sZoneLocal";
hint "";

Edited by psvialli

Share this post


Link to post
Share on other sites

If you set the _grpP on the main scope in the begining of that script it will work.

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  

×