Jump to content
Sign in to follow this  
ironhawx

Resyning modules upon death/destruction

Recommended Posts

I've searched all day and all yesterday for an answer on the subject but nothing clear or helpful. Basically I need to know how to with script or whatever, to when vehicle/player respawns the modules in question get readded to said player/vehicle. An example is using Nimitz Carrier Mod and need the catapult module to be resynced to my F/A 18 when it respawns. Any help would be much appreciated thank you.

Share this post


Link to post
Share on other sites

init line

this addEventHandler ["Respawn", {call TAG_ModuleSync}];

init.sqf

TAG_ModuleSync = {myModuleName synchronizeObjectsAdd [(_this select 0)];}; 

Edited by Iceman77

Share this post


Link to post
Share on other sites

This is a script i use to re-add supports from the BIS support module to the leader of a group in a mission with teamswitch. So when the leader dies and the second in command takes over, he willget access to the supports.

_grp = group _this;

while {(count units _grp) > 0} do {
_ldr = leader _grp;

waitUntil{!alive _ldr};

_oldUnit = _ldr;
_oldProviders = _oldUnit getVariable ["BIS_SUPP_allProviderModules", []];
_HQ = _oldUnit getVariable ["BIS_SUPP_HQ", nil];

waitUntil{((leader _grp) != _ldr) && ((leader _grp) == player)};
_ldr = leader _grp;

if ((count _oldProviders) > 0) then {
	{
		_providerModule = _x;
		{
			if (typeOf _x == "SupportRequester" && _oldUnit in (synchronizedObjects _x)) then {
				[_ldr, _x, _providerModule] call BIS_fnc_addSupportLink;
			};
		} forEach synchronizedObjects _providerModule;
	} forEach _oldProviders;
};

{
	_used = _oldUnit getVariable [format ["BIS_SUPP_used_%1",_x], 0];
	_ldr setVariable [format ["BIS_SUPP_used_%1", _x], _used, true]
} forEach [
	"Artillery",
	"CAS_Heli",
	"CAS_Bombing",
	"UAV",
	"Drop",
	"Transport"
];

_ldr setVariable ["BIS_SUPP_transmitting", false];
_ldr kbAddTopic ["BIS_SUPP_protocol", "A3\Modules_F\supports\kb\protocol.bikb", "A3\Modules_F\supports\kb\protocol.fsm", {call compile preprocessFileLineNumbers "A3\Modules_F\supports\kb\protocol.sqf"}];

if (!(isNil "_HQ")) then {
	_ldr setVariable ["BIS_SUPP_HQ", _HQ];
};
};

  • Thanks 1

Share this post


Link to post
Share on other sites
init line

this addEventHandler ["Respawn", {call TAG_ModuleSync}];

init.sqf

TAG_ModuleSync = {myModuleName synchronizeObjectsAdd [(_this select 0)];}; 

So where myModuleName is the name of the module (as i named in editor not the way its names from drop down list when selecting mod to put down) and i assume this will work on a vehicle as well, and this goes in the init.sqf so I can use any respawn script correct?

Share this post


Link to post
Share on other sites

Double click on your module, and at the very top give it a name. ie; myModuleName. Add the eventhandler to a units init line. Paste that one liner into your init.sqf. If you don't have an init.sqf, make one and paste the code in there, make sure it's in your mission directory. Not sure how you're respawning the vehicle, but you need to run the sync command on it after it gets created.

ie;

_veh = createVehicle ["ah1w", getPos myPos, [], 0, "CAN_COLLIDE"];  
myModuleName synchronizeObjectsAdd [_veh];

Edited by Iceman77

Share this post


Link to post
Share on other sites

Dependant on what module you are trying to resync there may be more needed than just resyncing the player to the module, as IndeedPete shows for supports.

See THIS thread for the original discussion on resyncing support modules.

Edited by Larrow

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  

×