Jump to content
Sign in to follow this  
semedar

Add Action When Object Destroyed And Keep It After Respawn?

Recommended Posts

I've got a mission when you destroy an enemy radar, you (player) get the option to use SATCOM

Trigger:

Condition: !Alive Radar

On Act:

player addAction [("<t color=""#FFFF00"">" + ("SATCOM") +"</t>"), "pxs_satcom_oa\start_satellite.sqf"];

But the problem is: When the player dies and respawns, he looses the ability.

Can anyone help me with my predicament? :D

Share this post


Link to post
Share on other sites

Just add it back when he dies either in whatever respawn script you're using or use a loop that waits for the player to be alive.

Share this post


Link to post
Share on other sites

If I add it to the respawn script, if the player dies before destroying the object (Radar), then he will automatically have said AddAction. I want it to be conditional somehow to where it detects if object "Radar" is destroyed first. And this is where I'm having problems with.

Share this post


Link to post
Share on other sites

Add the action from the beginning, remove the trigger and put in a condition instead.

player addAction [("<t color=""#FFFF00"">" + ("SATCOM") +"</t>"), "pxs_satcom_oa\start_satellite.sqf",[],1,false,true,"","!alive radar"];

Share this post


Link to post
Share on other sites
Add the action from the beginning, remove the trigger and put in a condition instead.

player addAction [("<t color=""#FFFF00"">" + ("SATCOM") +"</t>"), "pxs_satcom_oa\start_satellite.sqf",[],1,false,true,"","!alive radar"];

Ah! Sweet man, thanks! :D

EDIT:

I tried using the above example but I can't seem to get it to work. =\

I'm using a Save Layout respawn and tried this:

WaitUntil{not isNull player || isDedicated};

player addEventHandler ["Killed",{
player spawn {

	_unit = _this;

	private ['_magazines','_weapons','_backpack','_backpackweap','_backpackmags'];
	if(isNil "savedloadout") then {
		_weapons = weapons _unit;
		_magazines = magazines _unit;
		_backpack = typeOf unitBackpack _unit;
		_backpackmags = getMagazineCargo unitBackpack _unit;
		_backpackweap = getWeaponCargo unitBackpack _unit;
	} else {
		_weapons = savedloadout select 0;
		_magazines = savedloadout select 1;
		_backpack = savedloadout select 2;
		_backpackmags = savedloadout select 3;
		_backpackweap = savedloadout select 4;
	};

	WaitUntil{alive player};
	[color="Red"]player addAction [("<t color=""#FFFF00"">" + ("SATCOM") +"</t>"), "pxs_satcom_oa\start_satellite.sqf",[],1,false,true,"","!alive Radar"];[/color]
	removeAllWeapons player;
	removeAllItems player;
               removeBackpack player;
	{player addMagazine _x} foreach _magazines;
	{player addWeapon _x} foreach _weapons;
	if (primaryWeapon player != "") then {
      			player selectWeapon (primaryWeapon player);
        	_muzzles = getArray(configFile>>"cfgWeapons" >> primaryWeapon player >> "muzzles"); // Fix for weapons with grenade launcher
	        player selectWeapon (_muzzles select 0);
	};
	if(_backpack != "") then {
		player addBackpack _backpack; clearWeaponCargo (unitBackpack player); clearMagazineCargo (unitBackpack player);

		for "_i" from 0 to (count (_backpackmags select 0) - 1) do {
			(unitBackpack player) addMagazineCargo [(_backpackmags select 0) select _i,(_backpackmags select 1) select _i];
		};
		for "_i" from 0 to (count (_backpackweap select 0) - 1) do {
			(unitBackpack player) addWeaponCargo [(_backpackweap select 0) select _i,(_backpackweap select 1) select _i];
		};
	};
};
}];

EDIT 2: Hah nevermind ;) User error. :whistle:

Edited by Semedar

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  

×