Jump to content
Sign in to follow this  
sabot10.5mm

Support module

Recommended Posts

i created a single player mission with player respawn, synced with a few support modules. i have a problem with syncing the modules back to the player, it just wont work. even manualy syncing using THIS wont work.. 

 
player addAction ["sync arty", {
[player, req, arty] call bis_fnc_addsupportlink;
}];
 
player addAction ["sync drop", {
[player, req, supply] call bis_fnc_addsupportlink;
}];
 
there is a carvate to this. it works after killing the ai then killing the player
i suspect the ai leader is taking control of support

Share this post


Link to post
Share on other sites

this is the code i am using to respawn the player. supports sometimes isnt synced to the player on respawn

/*
A script for SP Respawn.
By Twirly - 6th July 2011
*/

private ["_plyr","_kilr","_type","_group","_dist","_camera","_found","_rand","_unit"];

_plyr = _this select 0;
_kilr = _this select 1;
_mrkr = if (count _this >2) then {_this select 2};

if (isNil "_kilr") then {_kilr = objNull};

//grab some stuff we need later
_type = typeOf _plyr;
_group = group _plyr;
_dist = _plyr distance _kilr;

if (count _this > 2) then {
//if (not (isNil _mrkr)) then {
	//create the new unit.... same group
	_unit = _group createUnit [_type, (getMarkerPos _mrkr), [], 1, "COLONEL"];
	sleep 2;
	addSwitchableUnit _unit;
	selectPlayer _unit;
	_unit setUnitRank "COLONEL";
	waitUntil {_unit == player};
	_found = true;
    _oldUnit = _this select 1;
    _oldGroup = group _oldUnit;
        
    //We dont care if he was not the leader
    if (leader _oldGroup == _oldUnit) then {
        
        h = [_oldUnit, _oldGroup] spawn {
            
            _oldUnit = _this select 0;
            _oldGroup = _this select 1;
            
            _oldProviders = _oldUnit getVariable ["BIS_SUPP_allProviderModules",[]];
            _HQ = _oldUnit getVariable ["BIS_SUPP_HQ",nil];

            //Wait for a new leader to be assigned            
            waitUntil { leader _oldGroup != _oldUnit };
            _leader = leader _oldGroup;
    
            if ((count _oldProviders) > 0) then {
              {
                    _providerModule = _x;
                    {
                         if (typeOf _x == "SupportRequester" && _oldUnit in (synchronizedObjects _x)) then {
                              [_leader, _x, _providerModule] call BIS_fnc_addSupportLink;
                         };
                    }forEach synchronizedObjects _providerModule;
              }forEach _oldProviders;
            };
           
            {
              _used = _oldUnit getVariable [format ["BIS_SUPP_used_%1",_x], 0];
              _leader setVariable [format ["BIS_SUPP_used_%1", _x], _used, true]
            } forEach [
              "Artillery",
              "CAS_Heli",
              "CAS_Bombing",
              "UAV",
              "Drop",
              "Transport"
            ];
            _leader setVariable ["BIS_SUPP_transmitting", false];
            _leader 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 {
              _leader setVariable ["BIS_SUPP_HQ", _HQ];
            };
        };
    };  

        
   
        
} else {
	//try to find a random playable unit
	while {(not (_found)) and ((count switchableunits) >=1)} do {
		_unit = switchableunits select (floor (random (count switchableunits)));
		if (alive _unit) then {
			_found = true;
			selectplayer _unit;
		};
		sleep 1;
	};
};


Edited by battlecarrysabot

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  

×