Jump to content

Recommended Posts

I am using the following at the moment:-

_markertsk=task1;
_marker1 = ["MissionAO",getpos _markertsk,"PERSIST"] call CBA_fnc_createMarker;

_markertsk=task2;
_marker2 = ["MissionAO",getpos _markertsk,"PERSIST"] call CBA_fnc_createMarker;

I am moving "MissionAO " marker around when i start a new task which works great and works for JIP as well. however I need a mission that does not use CBA

any idea or suggestion on the best way ?

Share this post


Link to post
Share on other sites

Wouldn't simple PV suffice for storing the current marker position?

Share this post


Link to post
Share on other sites

Pretty sure CBA just uses setPos (getPos). Try this in your init.sqf:

[] spawn {
   waitUntil {sleep 3.0; !isNil {getMarkerPos "MissionAO"}};
   "MissionAO" setMarkerPos (getMarkerPos "MissionAO");
};

Disclaimer: Above content might is not tested and might contain syntax error.

Share this post


Link to post
Share on other sites

Ok Still cannot get this to work without using CBA -

Basically I have say 10 missions which are selected at random then when a mission is assigned it create the marker so they spawn at the mission point.

My issue is not just moving the marker but also to make it JIP as well, hence using CBA but i really need a way without using CBA

This is what i have in my ini, after a mission is completed I delete the marker MissionAO then recreate it again so it all works with JIP:-

  		 _vehicleambush=task1;
	_marker1 = ["MissionAO",getpos _vehicleambush,"PERSIST"] call CBA_fnc_createMarker;

Any suggestions on how to get this to work without using CBA would be most welcome !

call compile preprocessfile "shk_taskmaster.sqf";
SHK_addTask = {
 if isserver then {
   if (count SHK_Tasks == 0) then {
     TheEnd = true;
     publicvariable "TheEnd";
   } else {
     _this spawn {
       private "_t";
       if (count _this > 0) then {
         _t = _this select 0;
       } else {
         _t = SHK_Tasks select (floor random count SHK_Tasks);
       };
       SHK_Tasks = SHK_Tasks - [_t];
       switch _t do {
case 0: {
 		["Task1","Capture VIP","You must locate and capture the VIP that is in the town of Stremidad and return him to your Base",true,["markertask1",getmarkerpos "task1","flag","ColorGreen"]] call SHK_Taskmaster_add;
  		nul = [] execVM "missions\task1.sqf";
 		 _vehicleambush=task1;
	_marker1 = ["MissionAO",getpos _vehicleambush,"PERSIST"] call CBA_fnc_createMarker;
   		};
   	case 1: {
 		["Task2","Escort Doctor","Your Mission is to safely transport the local Doctor and his vehicles to San Miguel- Your mission will be a failure if he dies. ",true,[["markertask2a",getmarkerpos "task2","start","ColorGreen"],["markertask2b",getpos task2end,"end","ColorGreen"]]] call SHK_Taskmaster_add;
  		nul = [] execVM "missions\task2.sqf";
    		 _vehicleambush=task2;
	_marker2 = ["MissionAO",getpos _vehicleambush,"PERSIST"] call CBA_fnc_createMarker;
  		};
   	case 2: {
 		["Task3","Assassination","We have just received Intel that the Head Warlord is located somewhere in the North West Region we have possible location as marked on the map the he you are to assassinate him when you locate him and clear the area of any of his troops",true,["markertask3",getmarkerpos "task3","flag","ColorYellow"]] call SHK_Taskmaster_add;
	nul = [] execVM "missions\task3.sqf";
	_vehicleambush=task3;
	_marker3 = ["MissionAO",getpos _vehicleambush,"PERSIST"] call CBA_fnc_createMarker;
  		 };
   	case 3: {
   		["Task4","Roadblock and Airfield","You are to Clear all 4 Roadblock that are heading up towards the Airfield then you are tasked to locate and Destroy the 3 helicopter ",true,["markertask4",getmarkerpos "task4","flag","ColorYellow"]] call SHK_Taskmaster_add;
	nul = [] execVM "missions\task4.sqf";
	 _vehicleambush=task4;
	_marker4 = ["MissionAO",getpos _vehicleambush,"PERSIST"] call CBA_fnc_createMarker;
  		 };
     case 4: {
   		["Task5","Antenna","A antenna has been sighted you are to destroy the it and sweep the area",true,["markertask5",getmarkerpos "task5","flag","ColorYellow"]] call SHK_Taskmaster_add;
	nul = [] execVM "missions\task5.sqf";
	_vehicleambush=radarsite2;
	_marker5 = ["MissionAO",getpos _vehicleambush,"PERSIST"] call CBA_fnc_createMarker;
  	      };
     case 5: {
	["Task6","Docks and Helicopter","Your first part of the mission is to recapture 4 stolen Boats they are located at the Docks where marked, once you have secured these transport them to the coastline and use them to get to the main AO where you are to destroy the ammo cash and also recover the stolen helicopter that is at the airfield and return it to your Base, DO NOT fly direct to the Island due to AA sites on the island. clera them out before you bring any Air asset near",true,[["markertask2a",getmarkerpos "task6","flag","ColorGreen"],["markertask2b",getpos boat1,"mil_pickup","ColorGreen"]]] call SHK_Taskmaster_add;
  		nul = [] execVM "missions\task6.sqf";
    		 _vehicleambush=task6;
	_marker6 = ["MissionAO",getpos _vehicleambush,"PERSIST"] call CBA_fnc_createMarker;
  	      };
      case 6: {
     	["Task7","Ammo Crates","We have Intel that there is 5 Ammo crates located in the village of Tigeria that we believe we have the location of two of them but the rest must be hidden in the main town you are tasked to destroy all 5 crates",true,["markertask7",getmarkerpos "task7","flag","ColorYellow"]] call SHK_Taskmaster_add;
	nul = [] execVM "missions\task7.sqf";
	 _vehicleambush=task7;
	_marker7 = ["MissionAO",getpos _vehicleambush,"PERSIST"] call CBA_fnc_createMarker;
  	      };
     case 7: {
   		["Task8","Locate HQ","Locate there HQ site and destroy it, +remember to take some satchel charges with you",true,["markertask8",getmarkerpos "task8","flag","ColorYellow"]] call SHK_Taskmaster_add;
	nul = [] execVM "missions\task8.sqf";
	 _vehicleambush=task8can;
	_marker8 = ["MissionAO",getpos _vehicleambush,"PERSIST"] call CBA_fnc_createMarker;
  	     };
     case 8: {
   		["Task9","UAV Terminal","Locate the UAV Terminal and destroy it, remember to take some satchel charges with you",true,["markertask9",getmarkerpos "task9","flag","ColorYellow"]] call SHK_Taskmaster_add;
	nul = [] execVM "missions\task9.sqf";
	_vehicleambush=task9;
	_marker9 = ["MissionAO",getpos _vehicleambush,"PERSIST"] call CBA_fnc_createMarker;
  	     };
     case 9: {
   		["Task10","Vehicle Drop","We have a C130 that is short on fuel and has to eject some cargo, you are to get there ASAP and collect the dropped Jackal and return it to your base, If OPFOR get it back to there base it will be a mission Failure",true,[]] call SHK_Taskmaster_add;
	nul = [] execVM "missions\task10.sqf";
	 _vehicleambush=testtimer;
	_marker10 = ["MissionAO",getpos _vehicleambush,"PERSIST"] call CBA_fnc_createMarker;
  	     };
     case 10: {
   		["Task11","Locate Ammo","We have Intel on 2 ammo crates one is located in Casa de la Muerte and the other in Chez Leon, once you have found theses and destroyed them you are to proceed to the Barracks in Campo and take down the Antenna. ",true,[]] call SHK_Taskmaster_add;
	nul = [] execVM "missions\task11.sqf";
	_vehicleambush=task11;
	_marker11 = ["MissionAO",getpos _vehicleambush,"PERSIST"] call CBA_fnc_createMarker;
  	     };
     case 11: {
   		["Task12","OPFOR Convoy","OPFOR have an ammo truck and a HQ BMP which is at their Airbase they need to get these vehicles safely to the marker on the Map it is your Job to destroy them before they reach there destination ",true,[["markertask12a",getmarkerpos "task12","start","ColorRed"],["markertask12b",getpos task12end,"end","ColorRed"]]] call SHK_Taskmaster_add;
   		nul = [] execVM "missions\task12.sqf";
	_spawnplace=task12;
	_marker12 = ["MissionAO",[11935,4303.87,0.0+0143814],"PERSIST"] call CBA_fnc_createMarker;
  	     };
        case 12: {
   		["Task13","Rescue Pilot","Whilst carrying out a low level photography sweep of to A.O, a C-130 was shot down. The pilot survived the crash and was able to extract the vital Intel, You are to locate the pilot and return him to the F.O.B.",true,["markertask13",getmarkerpos "task13","flag","ColorYellow"]] call SHK_Taskmaster_add;
   		nul = [] execVM "missions\task13.sqf";
	_vehicleambush=task13a;
	_marker13 = ["MissionAO",getpos _vehicleambush,"PERSIST"] call CBA_fnc_createMarker;
  	     };
       };
     };
   };
 };
};
private "_selectedTask";
taskCount = paramsarray select 4;
_selectedTask = paramsarray select 5;
if isserver then {
 private ["_tmp","_t"];
 _tmp = [0,1,2,3,4,5,6,7,8,9,10,11,12];
 SHK_Tasks = [];
 for "_i" from 0 to (taskCount - 1) do {
   _t = _tmp select (floor random count _tmp);
   SHK_Tasks set [_i,_t];
   _tmp = _tmp - [_t];
 };
 // first task
 if (_selectedTask < 99) then {
   [_selectedTask] call SHK_addTask;
 } else {
   [] call SHK_addTask;
 };
};


Edited by psvialli

Share this post


Link to post
Share on other sites

as stated in

http://forums.bistudio.com/showthread.php?t=123821

method that does not use CBA- tried and tested as i use it all the time!

init.sqf

if (isServer) then 
{
"objmkr" addPublicVariableEventHandler 
{
	_marker = createMarker [((_this select 1) select 0), position ((_this select 1) select 1)];
	"markertask" setMarkerShape "ELLIPSE";
	"markertask" setMarkerType "DOT";
	"markertask" setMarkerSize [120, 120];
	"markertask" setMarkerColor "ColorRed";
};
};
sleep 10; //need a sleep as wont show up if lots loaded in init.sqf
onplayerConnected {execVM "setingamemarkers.sqf"};

markerscript.sqf - called via whatever means

//pre-placed invisible markers
_preplacedmkr = ["task1", "task2","task3","task4"] call BIS_fnc_selectRandom;
_markname = "markertask";
			if (isServer) then 
			{					
			_marker = createMarker [_markname, position _preplacedmkr];
			"markertask" setMarkerShape "ELLIPSE";
			"markertask" setMarkerType "DOT";
			"markertask" setMarkerSize [120, 120];
			"markertask" setMarkerColor "ColorRed";
			} 	
			else
			{			
			objmkr = [_markname, _preplacedmkr]; publicVariable "objmkr";				
			};

		 [] spawn whateveryou script that randomly chooses the task;
		};

setingamemkr.sqf

"markertask" setMarkerPos (getMarkerPos "markertask");

Share this post


Link to post
Share on other sites

If a marker is global (created with createMarker), it will be show buggy behavior when someone JIPs, and generally its position will not be the correct one. This have been driving me crazy until I figured it out, as a script set up the UPSMON marker position, but then as players were loading the mission the marker position would jump around, causing UPSMON to send the units to patrol the wrong area! So another tip: Create markers locally (on the server) for UPSMON if you ever intend to move them.

The most simple way, I think, is to create markers locally and make sure they are updated locally for each client based on a position which you broadcast from the server with a publicVariable. Use waitUntil {!isNil "posVar"} and "posVar" addPublicVariableEventHandler {...}; on clients, and keep in mind the event handler will not run on the server, so to make it compatible with a hosted server you will need to update the position on the host when you publicVariable the position.

Another option you have is to simply look at the CBA function and see what it does, it'll likely have an even better solution.

If you need a sleep in your script just to make it work, you're probably doing something very wrong, and it's best you figure it out rather than try work around it with a sleep command.

Edited by galzohar

Share this post


Link to post
Share on other sites

Above method i detailed works fine. sleep command is purely to ensure the markers move when player init - it does not form part of the script per se- You could easily changed it for a waituntil command in the setingamemkr.sqf. To say it is "very wrong" is a bit harsh - anyway it is one simple way to get markers JIP if all other methods fail.

Share this post


Link to post
Share on other sites

I have tried this but just cannot get it to work anyway you can put a simple mission with it in so i have have a look and see how it works ?

Thanks

as stated in

http://forums.bistudio.com/showthread.php?t=123821

method that does not use CBA- tried and tested as i use it all the time!

init.sqf

if (isServer) then 
{
"objmkr" addPublicVariableEventHandler 
{
	_marker = createMarker [((_this select 1) select 0), position ((_this select 1) select 1)];
	"markertask" setMarkerShape "ELLIPSE";
	"markertask" setMarkerType "DOT";
	"markertask" setMarkerSize [120, 120];
	"markertask" setMarkerColor "ColorRed";
};
};
sleep 10; //need a sleep as wont show up if lots loaded in init.sqf
onplayerConnected {execVM "setingamemarkers.sqf"};

markerscript.sqf - called via whatever means

//pre-placed invisible markers
_preplacedmkr = ["task1", "task2","task3","task4"] call BIS_fnc_selectRandom;
_markname = "markertask";
			if (isServer) then 
			{					
			_marker = createMarker [_markname, position _preplacedmkr];
			"markertask" setMarkerShape "ELLIPSE";
			"markertask" setMarkerType "DOT";
			"markertask" setMarkerSize [120, 120];
			"markertask" setMarkerColor "ColorRed";
			} 	
			else
			{			
			objmkr = [_markname, _preplacedmkr]; publicVariable "objmkr";				
			};

		 [] spawn whateveryou script that randomly chooses the task;
		};

setingamemkr.sqf

"markertask" setMarkerPos (getMarkerPos "markertask");

Share this post


Link to post
Share on other sites

my bad - bit of duff coding - the above code should have been for game logics -

in editor - create three markers "marker1", "marker2", and "marker3"

create one maker "respawn_west" - for JIP test

and place one payer on the map - add - this setcaptive true - to init of player, and also - this addaction ["call marker","markerchange.sqf"];

next place a function module anywhere on the map

next the init.sqf

if (isServer) then 
{
"objmkr" addPublicVariableEventHandler 
{
	_marker = createMarker [((_this select 1) select 0), getmarkerpos ((_this select 1) select 1)];
	"markertask" setMarkerShape "ELLIPSE";
	"markertask" setMarkerType "DOT";
	"markertask" setMarkerSize [50, 50];
	"markertask" setMarkerColor "ColorRed";
};
};

onplayerConnected {execVM "setingamemarkers.sqf"};

then description file

respawnDelay = 15;
respawn = 3;
respawnDialog = 1;
disabledAI = 1;

class Header
{
gameType = COOP;            ////DM, CTF, FF, Coop, Team, Scont, Hold, Unknown
minPlayers = 1;             //min # of players the mission supports
maxPlayers = 10;            //Max # of players the mission supports
playerCountMultipleOf = 1;  //OFP:Elite option.
};

then markerchange.sqf

waituntil {!isnil "BIS_fnc_init"};
deletemarker "markertask";
sleep 2;
//pre-placed invisible markers
_preplacedmkr = ["marker1","marker2","marker3"] call BIS_fnc_selectRandom;
_markname = "markertask";
			if (isServer) then 
			{					
			_marker = createMarker [_markname, getmarkerpos  _preplacedmkr];
			"markertask" setMarkerShape "ELLIPSE";
			"markertask" setMarkerType "DOT";
			"markertask" setMarkerSize [50, 50];
			"markertask" setMarkerColor "ColorRed";
			} 	
			else
			{			
			objmkr = [_markname, _preplacedmkr]; publicVariable "objmkr";				
			};

		hint "spawned marker";
		execvm "creategroup.sqf";

then creategroup.sqf

waituntil {!isnil "bis_fnc_init"};
//    a = [unit] execVM "ca\modules\garbage_collector\data\scripts\trashIt.sqf"  // for use with garbage collector

sleep 2;
//taskpatrol
for "_i" from 0 to 1 do     //creates 31
{
//		_vehicletype = ["BRDM2_TK_EP1", "BTR40_TK_INS_EP1"] call BIS_fnc_selectRandom;
	_distances = [10,20] call BIS_fnc_selectRandom;
	_ang = random 360;  	
	_dis = _distances; 
	_dx = sin(_ang)*_dis; 
	_dy = cos(_ang)*_dis; 
	_loc = [((getmarkerpos "markertask") select 0) + _dx, ((getmarkerpos "markertask") select 1) + _dy, 0];
	_terrorsupportteam = [_loc, EAST, ["TK_INS_Bonesetter_EP1", "TK_INS_Soldier_2_EP1", "TK_INS_Soldier_Sniper_EP1", "TK_INS_Soldier_2_EP1","TK_INS_Soldier_2_EP1"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;

	_terrorsupportteam spawn {
	_units = units _this;
	waitUntil {sleep 20; 
	({alive _x} count _units) == 0};
	{deleteVehicle _x} foreach _units;
	deleteGroup _this;
	};
	[_terrorsupportteam, getmarkerPos "markertask", _distances] call BIS_fnc_taskPatrol;
};

then setingamemarkers.sqf

sleep 2;


"markertask" setMarkerPos (getMarkerPos "markertask");

tested and ALL works perfectly.

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  

×