Jump to content
Sign in to follow this  
Flens

Setcaptive false for any player upon vehicle exit

Recommended Posts

[] spawn {

waitUntil {!isNull player};

waitUntil {vehicle player != player};

waitUntil {vehicle player == player};

player setCaptive false;

};

This is what I have running in the init right now, it sort of works but not really.

opfor won't become hostile immediately but only after I open fire on them.

I checked to make sure the mission hadn't set indfor friendly to opfor and they weren't.

Is there any simpler way to make opfor become hostile as soon as any player exits any vehicle?

Share this post


Link to post
Share on other sites

Try this (untested):

{
_x addEventHandler ["GetOut",
{
	if (isPlayer (_this select 2)) then {(_this select 2) setCaptive false};
}];
} forEach vehicles;

Share this post


Link to post
Share on other sites

No dice, had no luck at all with your script

Share this post


Link to post
Share on other sites

Shouldn't be the case. In my editor tests, enemies always open fire at me as soon as I remove the setCaptive flag. Are you sure they know about you (knowsAbout > 1.5)?

Share this post


Link to post
Share on other sites

Not sure why you are [] spawn'ing. Doesn't break it, but causes unnecessary checks that may hang up on you later on if you reuse captive or the vehicle. Just something to keep in mind.

If the enemies aren't looking at you and you setCaptive false, basically spawning an enemy behind their back, they won't detect you. You can however throw an AutoTarget in there.

Share this post


Link to post
Share on other sites

I'm guessing he's spawning the code to run it in a new thread so the rest of the script can continue and not be halted by the waituntils.

Share this post


Link to post
Share on other sites

If OPFOR opens fire once you open fire on them it means the script works. On the other hand, the AI doesn't know about you until you open fire at them (ie they're not looking at you). Try setting the knowsAbout value of an OPFOR unit in the vicinity of the player to 4 and see if that unit reacts as soon as the player exits.

Share this post


Link to post
Share on other sites

Did some testing and apparently just not setting the players as captive in the first place works fine.

Share this post


Link to post
Share on other sites

Glad you got it sorted.

Just to further the topic; the example I posted earlier wouldn't work because of our good old friend - locality. The arguments of setCaptive are local, and from what I understand, the command must be run on the machine that "owns" the player.

So we can try this:

"GetOut" EH only fires on PC where it was added. We also need to know which machine to run the command on, which we can find out by running the owner command on the server. Ergo, run this only on server!

{ 
   _x addEventHandler ["GetOut", 
   { 
	_unit = _this select 2;
	if (isPlayer _unit) then
	{
		_ownerID = owner _unit;
		[[_unit],"horde_fnc_setCapVehExit",_ownerID, false] call BIS_fnc_MP;	
	};
   }]; 
} forEach vehicles;

So that should tell the "owner" PC of the player to run a function called horde_fnc_setCapVehExit.

Then the PC of the exiting player runs this code. Add it in init.sqf or somewhere that all players PC's can read it from.

horde_fnc_setCapVehExit = 
{
_unit = _this select 0;
_unit setCaptive false;
};

See how you get on with that.

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  

×