Jump to content
darkdespair55

Covert VIP ambush - SetCaptive issue

Recommended Posts

Hello All, 

So I am trying to make a CIA style mission based around one of the redone buildings on Cam Lao Nam (Multiplayer, self or server hosted).   The players will start off as unarmed Blufor operatives in civis and take a ride on Air America.  I know I need to use the setCaptive command but I am having issues with the event handler to remove this status. I am using eden editor and not putting extra script files in, just doing it all via the character init boxes. I found some of the below code on an older post but cant get it to work right.  In this case SL1 is the squad leader and I'm trying this all just on one before copying it over. 

The goal is that when the player equips a weapon from the virtual arsenal box I have hidden in a van near the objective they lose the setCaptive state. Any help debugging whats below would be appreciated. 


*INIT BOX (Of the player)* 

 


removeAllWeapons SL1; //remove the weapons and items from default characters inventory
removeAllItems SL1; 
removeAllAssignedItems SL1;
SL1 setCaptive true; //set initial captive state

this addEventHandler ["Take", {  
   
 _unit = _this select 0; //at one point it would error out if I had this set at 0 but it seems to be accepting it now. *EDIT/Updated*
 _item = _this select 2; 
   
 if ((_item isKindOf ["Rifle", configFile >> "CfgWeapons"]) || (_item isKindOf ["Pistol", configFile >> "CfgWeapons"]) || (_item isKindOf ["Launcher", configFile >> "CfgWeapons"])) then   
  {  
   _unit setCaptive false; //this is what was in the example
   [_unit, false] remoteExec["setCaptive"]; //tried adding server remote call and it didnt change anything. 
   hint "You picked up a weapon enemies will now be hostile!";  
  };   
}]; 
myfancygroup = group this; //This is for a helicopter to know the whole spawned group is onboard before taking off

Share this post


Link to post
Share on other sites
Quote

_unit = _this select 1;  //example has a 0 here but the editor rejects it as an invalid number so I incremented +1   

 

You can't choose your own syntax. In this case, _unit now refers to the container.

 

From the Biki:

Quote

unit: Object - unit to which the event handler is assigned

 

So, add your event handler to the player, not the box.

 

Keep things clear by using the given params:

this addEventHandler ["Take", {
	params ["_unit", "_container", "_item"];
	
	if ((_item isKindOf ["Rifle", configFile >> "CfgWeapons"]) || (_item isKindOf ["Pistol", configFile >> "CfgWeapons"]) || (_item isKindOf ["Launcher", configFile >> "CfgWeapons"])) then   
	{  
		_unit setCaptive false;
		hint "You picked up a weapon - enemies will now be hostile!";  
	};  
}];

 

You shouldn't need to remoteExec setCaptive as it is GE.

Share this post


Link to post
Share on other sites
12 minutes ago, Harzach said:

 

You can't choose your own syntax. In this case, _unit now refers to the container.

 

 From the Biki:

 

So, add your event handler to the player, not the box.

Sorry if I made a confusing statement.   that is all in the init field of the player not of the arsenal box. I have had it show the hint but it failed to change setCaptive.  I tried again and it magically accepted 0 this time


However the "Take" action is not triggering on grabbing weapons from the virtual arsenal.  If the player drops a weapon then picks it up again it works. Is there a similar function to work with the virtual arsenal? 


 

Share this post


Link to post
Share on other sites
3 hours ago, darkdespair55 said:

virtual arsenal.

 

You don't "take" from the VA, that's the problem. It needs to be an ammobox with a real  inventory.

 

You could maybe check for weapons in player inventory while near the box, or something along those lines.

Share this post


Link to post
Share on other sites

or use:  weapons player isNotEqualTo []     (no need to specify)... in a little loop.

  • Like 1

Share this post


Link to post
Share on other sites
weapons player isNotEqualTo []

 

This will return true if the player has binoculars, though.

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

×