Jump to content
PSYKO_nz

set captive true/false on enter or exit of vehicle

Recommended Posts

sooooo the next step in my series if for the boys to steal a chopper ("h1")

what i would like to do is try and simulate the chopper being seen by opfor and indfor (both are in the mission) and the op/ind unit thinks its friendly - ie its one of their choppers in their paint, so it must be theirs 

 

i think set captive is the best way to do this, so i need to figure out a simple DS script that detects if a player is in the taru (h1) or any of its pods (p2, p3, p4) in any position (pilot, co pilot, loadmaster, in cargo) and sets that player to captive.

(except for the bench pod (p1) as the players can be seen by op/indfor

 

then

 

when that player gets out of the Taru (h1) the script sets captive false for them. 

 

this needs to happen for any player entering or exiting the taru, so if there are 4 players in taru/pods they are all captive

 

am i rambling or making sense? i can't tell haha

 

i've had a look at these
https://community.bistudio.com/wiki/setCaptive

and

but am still confused, i have used set captive before, quite a lot actually but never in this way!!!

 

Any ideas?

Share this post


Link to post
Share on other sites

Shouldn't setCaptive True work on the helo itself? So that no one shoots at it regardless of crew? 

Share this post


Link to post
Share on other sites

Don't bother with players or units. Name your helo (h1), then, in init.sqf or in a trigger set cond to true

 

[] spawn {
  while {alive h1} do {
    waituntil {sleep 0.5; {alive _x && _x in h1} count allPlayers > 0};
   h1 setCaptive true;
    waituntil {sleep 0.5; {alive _x && _x in h1} count allPlayers == 0};
    h1 setCaptive false;
  };
};

 

I forgot some EHs existance... But, at least, it's working...

  • Like 2

Share this post


Link to post
Share on other sites

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetIn

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetOut

 

HELI_1 addEventHandler ["getIn", {(_this select 2) setCaptive true; systemChat "You are now safe.";}];
HELI_1 addEventHandler ["getOut", {(_this select 2) setCaptive false; systemChat "You are no longer safe."}];

The above needs to run for all players, so put it in the init.sqf or in the heli/pods init.

  • Like 1

Share this post


Link to post
Share on other sites

Know your eventhandlers, they're always better than infinite loops. ;)

 

You could also use the EHs "getInMan" and "getOutMan". Those can be attached directly to the player, which would be useful if you plan on having several "undercover" vehicles.

  • Like 4

Share this post


Link to post
Share on other sites

If you used the "eject" option to exit the vehicle instead of "get out", then would this EH solution still work?

Share this post


Link to post
Share on other sites
Quote

 

Triggers when a unit exits a vehicle. Similar to "GetOut" but must be assigned to a unit and not vehicle. Persistent on respawn if assigned where unit was local. This EH is triggered by moveOut and "GetOut" & "Eject" actions.

 

Any regular way of entering/exiting a vehicle triggers it.

Share this post


Link to post
Share on other sites

Sorry for the late reply, i've been bust for a few days, thank you for all your responses!!! now all there is left to do is test them!

a NZArmA member suggested doing it via a trigger for each player that detects and changes captive status,

            dataType="Trigger";
            class Attributes
            {
                condition="call{(Psyko in H1) OR (Psyko in P2) OR (Psyko in P3) OR (Psyko in P4)}";
                onActivation="call{Psyko setCaptive true;}";
                onDeactivation="call{Psyko setCaptive false;}";
                sizeA=0;
                sizeB=0;
                repeatable=1;
};

 

Psyko = me ( we use our names as variable names to keep things easy)
H1 = the taru
P# = pod #

repeatable

 

and one for each player

 

i did a quick and dirty test where i had opfor and angry indfor shooting at a "psyko allowdamage false" player.....

Boss walked up to the taru (h1) under heavy fire, hopped in h1, bang bang stopped, chilled out in the cockpit for a bit then jumped out, pew pew pew. so at this stage it has worked. its easy to have and use, however i don't know how it will work on a ds or with many of us in different positions, so when we play this mission (this sunday) i will give it a proper run. if it doesn't work ill give some of these a shot!

i intend on this being a regular feature in my missions. once again thank you for your time and help thus far! 

 

i really really like the look of this one

 

On 9/15/2017 at 7:32 PM, lsd said:

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetIn

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetOut

 


HELI_1 addEventHandler ["getIn", {(_this select 2) setCaptive true; systemChat "You are now safe.";}];
HELI_1 addEventHandler ["getOut", {(_this select 2) setCaptive false; systemChat "You are no longer safe."}];

The above needs to run for all players, so put it in the init.sqf or in the heli/pods init.

 

 

looks much much cleaner than my mates idea, BUT i need to check his way first, i hope you understand :)

Share this post


Link to post
Share on other sites
1 hour ago, PSYKO_nz said:

a NZArmA member suggested doing it via a trigger for each player that detects and changes captive status,

Sorry to say but what your friend suggested there is pretty close to beeing the worst possible solution. :whistle:

 

By the way: Triggers are local to each client. So there is no reason to make a separate trigger for each of them. A single trigger that checks against "player" instead of "Psyko" is enough. Also I see no need to put call {} around all your trigger conditions.

 

Personally, I would simply put this in the init.sqf:

if ( isServer ) then {
	missionNamespace setVariable ["captiveVehicles", [H1,P1,P2,P3], true];
};

if (!isDedicated) then {
	player addEventHandler ["GetInMan", {
		params["_vehicle","_position","_unit"];
		if (_vehicle in captiveVehicles) then {
			_unit setCaptive true;
			systemChat "You are now undercover.";
		};
	}];
	player addEventHandler ["GetOutMan", {
		params["_vehicle","_position","_unit"];
		if (captive _unit) then {
			_unit setCaptive false;
			systemChat "You are no longer undercover.";	
		};
	}];
};

That way you can also add / remove vehicles later on by simply adding them to the captiveVehicles variable.

 

  • Like 4

Share this post


Link to post
Share on other sites
13 hours ago, Tajin said:

Sorry to say but what your friend suggested there is pretty close to beeing the worst possible solution. :whistle:

 

By the way: Triggers are local to each client. So there is no reason to make a separate trigger for each of them. A single trigger that checks against "player" instead of "Psyko" is enough. Also I see no need to put call {} around all your trigger conditions.

 

Personally, I would simply put this in the init.sqf:


if ( isServer ) then {
	missionNamespace setVariable ["captiveVehicles", [H1,P1,P2,P3], true];
};

if (!isDedicated) then {
	player addEventHandler ["GetInMan", {
		params["_vehicle","_position","_unit"];
		if (_vehicle in captiveVehicles) then {
			_unit setCaptive true;
			systemChat "You are now undercover.";
		};
	}];
	player addEventHandler ["GetOutMan", {
		params["_vehicle","_position","_unit"];
		if (captive _unit) then {
			_unit setCaptive false;
			systemChat "You are no longer undercover.";	
		};
	}];
};

That way you can also add / remove vehicles later on by simply adding them to the captiveVehicles variable.

 

 

 

dont be sorry at all, i'd rather get this right and learn how to do it and then show my mate it too, always better to learn by getting stuff wrong, so.... what will be the best choice for use? the one above or this one?

 

 

On 9/15/2017 at 7:32 PM, lsd said:

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetIn

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetOut

 


HELI_1 addEventHandler ["getIn", {(_this select 2) setCaptive true; systemChat "You are now safe.";}];
HELI_1 addEventHandler ["getOut", {(_this select 2) setCaptive false; systemChat "You are no longer safe."}];

The above needs to run for all players, so put it in the init.sqf or in the heli/pods init.

 

Share this post


Link to post
Share on other sites
On 9/19/2017 at 11:46 PM, Tajin said:

Sorry to say but what your friend suggested there is pretty close to beeing the worst possible solution. :whistle:

 

By the way: Triggers are local to each client. So there is no reason to make a separate trigger for each of them. A single trigger that checks against "player" instead of "Psyko" is enough. Also I see no need to put call {} around all your trigger conditions.

 

Personally, I would simply put this in the init.sqf:


if ( isServer ) then {
	missionNamespace setVariable ["captiveVehicles", [H1,P1,P2,P3], true];
};

if (!isDedicated) then {
	player addEventHandler ["GetInMan", {
		params["_vehicle","_position","_unit"];
		if (_vehicle in captiveVehicles) then {
			_unit setCaptive true;
			systemChat "You are now undercover.";
		};
	}];
	player addEventHandler ["GetOutMan", {
		params["_vehicle","_position","_unit"];
		if (captive _unit) then {
			_unit setCaptive false;
			systemChat "You are no longer undercover.";	
		};
	}];
};

That way you can also add / remove vehicles later on by simply adding them to the captiveVehicles variable.

 

 finally got round to testing this mission last night, no joy on this script, i was in H1 and i was still taking fire, also i didn't get the systemchat either i don't know if that has anything to do with it???

Share this post


Link to post
Share on other sites

Finally, mine works. For no real CPU load. Best is sometimes contrary of good...

  • Like 1

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

×