Jump to content
JohnKalo

Function only working for host

Recommended Posts

Hey guys just tested a mission and came up with an issue. I am using this code:

 

["init", [y, "images\spoilers.jpg", "Spoilers"]] call BIS_fnc_initLeaflet;

["init", [x, "images\spoilers.jpg", "Spoilers"]] call BIS_fnc_initLeaflet;

 

in an MP mission. All worked fine but one thing. The action to see the leaflet both times was only visible to the host. Clients could not even see the action. How can I make the above action visible to all in MP please?

Share this post


Link to post
Share on other sites
[ "init", [ x, "images\spoilers.jpg", "Spoilers" ]] remoteExec[ "BIS_fnc_initLeaflet", 0 ];

0 call function on all machines.

 

May want to add JIP queue as well? and possibly remove once examined? Something like...

Spoiler

//initPlayerLocal.sqf
//These functions should be defined via CfgFunctions to remove any initialisation timing issues

TAG_fnc_addLeaflet = {
	params[ "_leaflet", [ "_removeOnUse", false ] ];
	
	//Initialise leaflet
	[ "init", [ _leaflet, "images\spoilers.jpg", "Spoilers" ]] call BIS_fnc_initLeaflet;
	
	if ( _removeOnUse ) then {
		
		missionNamespace setVariable[ "TAG_leaflets", missionNamespace getVariable[ "TAG_leaflets", [] ] + [ _leaflet ] ];
		
		//On leaflet inspected
		[ missionNamespace, "objectInspected", {
			params[ "_leaflet" ];
			
			//If the inspected object is one of the leaflets added as _removeOnUse
			if ( _leaflet in ( missionNamespace getVariable[ "TAG_leaflets", [] ] ) ) then {
				
				//Remove examined Leaflets JIP queue item
				remoteExec[ "", format[ "JIP_Leaflet_%1", _leaflet call BIS_fnc_objectVar ] ];
				
				//Remove Leaflet holdAction on all machines
				[ _leaflet ] remoteExec[ "TAG_fnc_removeLeaflet", 0 ];
			};
				
		}] call BIS_fnc_addScriptedEventHandler;
	};
};

TAG_fnc_removeLeaflet = {
	params[ "_leaflet" ];
	
	_actionID = _leaflet getVariable[ "bis_fnc_initInspectable_actionID", -1 ];
	if ( _actionID > -1 ) then {
		[ _leaflet, _actionID ] call BIS_fnc_holdActionRemove;
	};
};



//initServer.sqf

{
	//Remote for all clients and JIP
	[ _x, true ] remoteExec[ "TAG_fnc_addLeaflet", 0, format[ "JIP_Leaflet_%1", _x call BIS_fnc_objectVar ] ];
		
}forEach[ x, y ];

 

 

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you very much for the detailed explanation! I will use the first method since the missions are not JIP friendly anyways. Also players might want to check the leaflets again for clues ;)

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

×