Jump to content
MIKUiqnw0

Issues with BIS_fnc_taskSetState

Recommended Posts

So I've been having issues getting my tasks to switch state when a player activates an action from specific units on the map.

The links provided throughout the post takes you to the Github where this mission resides, just in case more context is needed.

 

 

The tasks are created during server initialization with BIS_fnc_setTask:

...
["beginTask", BLUFOR, ["Or perhaps they can, that's up to you.<br/><br/>Either way, you and your questionably living crew are going to have to secure some kind of assistance and arsenal. Just last night, Jarate and a few other useless souls got the chop over there in that tent of yours - you can't keep this up anymore. Guns, ammo and food don't grow on trees either.<br/><br/>... Well, food might, but you lot are just desk sitters. What do you know?", "The living cannot survive alone", "This shouldn't show up"], getMarkerPos "respawn_west", "ASSIGNED", 0, true, true, "whiteboard", false] call BIS_fnc_setTask;
[["indepTask", "beginTask"], BLUFOR, ["So you've decided to go at it alone. Kind of.<br/><br/>A ragtag group of Chernarus National Guard and PMCs just north of your doomed encampment have setup shop near Zelenogorsk at the Green Mountain radio tower. They've been around the place during your scavenging runs and you've had some close calls with these folks. Can't blame 'em really, everyone else looks like the stuff of nightmares.<br/><br/>You might be able to get some trade going on with this lot with abit of luck, assuming their sentries don't put a bullet through your skull first.", "1. Independently Screwed", "1. Independently Screwed"], position VIPIndep, "CREATED", 1, true, true, "meet", false] call BIS_fnc_setTask;
[["ruskieTask", "beginTask"], BLUFOR, ["Todo", "2. Russian Recollection", "2. Russian Recollection"], position VIPRuskie, "CREATED", 1, true, true, "meet", false] call BIS_fnc_setTask;
[["mericaTask", "beginTask"], BLUFOR, ["Todo", "3. American Freedom", "3. American Freedom"], position VIPMerica, "CREATED", 1, true, true, "meet", false] call BIS_fnc_setTask;
...

Three units around the map are given a variant of the following init code to run:

this addAction ["Join Russia", { [EAST, _this#0, _this#2] remoteExec ["ZE_fnc_setSide", 2] }, nil, 1.5, true, true, "", "player distance VIPRuskie < 5", 5, false, ""];

The function called in the addAction activation code remote executes a server side function which manages the side changes and attempts to change the task states towards the end of the file:

...
publicVariable "zSideJIP";
switch(zSideJIP) do {
	case independent: {
		["indepTask", "SUCCEEDED", true] call BIS_fnc_taskSetState;
		["ruskieTask", "CANCELED", false] call BIS_fnc_taskSetState;
		["mericaTask", "CANCELED", false] call BIS_fnc_taskSetState;
	};
	case east: {
		["indepTask", "CANCELED", false] call BIS_fnc_taskSetState;
		["ruskieTask", "SUCCEEDED", true] call BIS_fnc_taskSetState;
		["mericaTask", "CANCELED", false] call BIS_fnc_taskSetState;
	};
	case west: {
		["indepTask", "CANCELED", false] call BIS_fnc_taskSetState;
		["ruskieTask", "CANCELED", false] call BIS_fnc_taskSetState;
		["mericaTask", "SUCCEEDED", true] call BIS_fnc_taskSetState;
	};
};
["beginTask", "SUCCEEDED", true] call BIS_fnc_taskSetState;

Unfortunately, the function completes everything except the change in task states and I'm not really sure how to proceed, considering the wiki tells me that the framework supposedly manages the synchronization so long as I've dealt with it on the server.

Any ideas?

Share this post


Link to post
Share on other sites

Only had a quick browse through the files...

 

You are adding your tasks to BLUFOR(west) but when they use the action on the VIP you are changing their side to the side of the base. Hence they are no longer West so the task update does not relate to them.

Instead of adding the tasks to BLUFOR use [p1,p2,p3,p4,p5] to give it specifically to those players.

["beginTask", [ p1, p2, p3, p4, p5 ], ["Or perhaps they can, that's up to you.<br/><br/>Either way, you and your questionably living crew are going to have to secure some kind of assistance and arsenal. Just last night, Jarate and a few other useless souls got the chop over there in that tent of yours - you can't keep this up anymore. Guns, ammo and food don't grow on trees either.<br/><br/>... Well, food might, but you lot are just desk sitters. What do you know?", "The living cannot survive alone", "This shouldn't show up"], getMarkerPos "respawn_west", "ASSIGNED", 0, true, true, "whiteboard", false] call BIS_fnc_setTask;
[["indepTask", "beginTask"], [ p1, p2, p3, p4, p5 ], ["So you've decided to go at it alone. Kind of.<br/><br/>A ragtag group of Chernarus National Guard and PMCs just north of your doomed encampment have setup shop near Zelenogorsk at the Green Mountain radio tower. They've been around the place during your scavenging runs and you've had some close calls with these folks. Can't blame 'em really, everyone else looks like the stuff of nightmares.<br/><br/>You might be able to get some trade going on with this lot with abit of luck, assuming their sentries don't put a bullet through your skull first.", "1. Independently Screwed", "1. Independently Screwed"], position VIPIndep, "CREATED", 1, true, true, "meet", false] call BIS_fnc_setTask;
[["ruskieTask", "beginTask"], [ p1, p2, p3, p4, p5 ], ["Todo", "2. Russian Recollection", "2. Russian Recollection"], position VIPRuskie, "CREATED", 1, true, true, "meet", false] call BIS_fnc_setTask;
[["mericaTask", "beginTask"], [ p1, p2, p3, p4, p5 ], ["Todo", "3. American Freedom", "3. American Freedom"], position VIPMerica, "CREATED", 1, true, true, "meet", false] call BIS_fnc_setTask;

 

------------------------------------------

 

indepBaseUnits apply { [_x] joinSilent (createGroup independent) };

This could cause problems with units not joining the group properly. It does not throw an error but #baseunits is an array of groups.

indepBaseUnits apply { units _x joinSilent (createGroup independent) };

 

------------------------------------------

 

_target removeAction _actionId;

This is only going to remove the action from the server and as you have the addAction in the objects init you will also need to remove it for JIP.

You would be better off adding the action from script with JIP, storing a reference to the action Id on the object for each client(as you cannot guarantee ID ), then once used remove from each client via stored Id and remove JIP queue that adds it.

//init server

{
	[_x] remoteExec [ "ZE_fnc_addVIPAction", [0,-2] select isDedicated, format[ "%1_action", vehicleVarName _x ] ];
}forEach [ VIPIndep, VIPRuskie, VIPMerica ];
//init client

ZE_fnc_addVIPAction = {
	params[ "_target" ];
	
	_actionTitle = [ "Join Russia", "Join NATO", "Join Chernarus National Guard / PMC" ] select ( side group _target call BIS_fnc_sideID );
	
	_id = _target addAction [ _actionTitle, {
			params [ "_target" ];
			
			[ _target ] remoteExec [ "ZE_fnc_setSide", 2 ];
		},
		[],
		1.5,
		true,
		true,
		"",
		//_target (unit to which action is attached to) and _this (caller/executing unit)
		"_this distanceSqr _target <= ( 5^2 )",
		5,
		false,
		""
	];
	
	_target setVariable[ "VIP_actionID", _id ];
};

ZE_fnc_removeVIPAction = {
	params[ "_target" ];
	
	//Get _target action ID
	_id = _target getVariable[ "VIP_actionID", -1 ];
	
	//If we have an Id
	if ( _id >= 0 ) then {
		//Remove the action
		_target removeAction _id;
	};
};
//Top of ZE_fnc_setSide
if(!isServer) exitWith {};

params[ "_target" ];
_side = side group _target;

{
	//Only remove _target action, others VIPs about to be deleted along with their base objects
	if ( _x isEqualTo _target ) then {
		//Remove VIP actions for all clients
		[ _x ] remoteExec [ "ZE_fnc_removeVIPAction", [0,-2] select isDedicated ];
	};
	//Remove JIP queue
	remoteExec[ "", format[ "%1_action", vehicleVarName _x ] ];
}forEach [ VIPIndep, VIPRuskie, VIPMerica ];

 

------------------------------------------

 

Remove base markers? Not sure if this is intentional or not?

_fncDelete = {
	params["_objects","_markers"];
	{
		deleteVehicle _x;
	} forEach _objects;
	{
		deleteMarker _x;
	} forEach _markers;
};

[_layers#1] call _fncDelete;

 

 

All thoroughly untested. :icon_biggrin:  but should give you a good idea of where to head.

  • Like 1

Share this post


Link to post
Share on other sites

Oh boy, went above and beyond with that one. I can finally move into developing further tasks with this problem clarified. Thank you so much. <3 :worship:

 

Seeing as the tasks remained in the player's task list after switching sides, I had wrongly assumed that the taskID string was all that mattered and that when the target parameter of BIS_fnc_setTask was given a side, it would act as if I'd given the function an array of all units from that side.

I doubt it would have occurred to me at all that changing sides would orphan those tasks, unless I had tried to test this with the Blufor VIP at some point, which I didn't.

 

I've implemented your other advisories as well, though I've had to preserve the side of each VIP via an additional parameter due to all bases having a trigger that changes their side to west at the beginning of the mission (So the players don't get shot on approach).

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

×