Jump to content
FullyAutoJuiceBox

player action ["Eject"] with setTriggerStatements activation param

Recommended Posts

Upon entering trigger area I'm trying to cut engine and eject the player from the _targetTruck.

 

 

_targetTruck = "rhsusf_M1078A1P2_B_D_CP_fmtv_usarmy" createVehicle _mark;

 

_returnTrig = createTrigger["EmptyDetector", _returnTrigPos];
_returnTrig setTriggerArea [5,5,0, false];
_returnTrig triggerAttachVehicle [_targetTruck];
_returnTrig setTriggerActivation ["VEHICLE", "PRESENT", true];
_returnTrig setTriggerStatements ["this",
    "player action ["engineOff", _targetTruck player]
     player action ["eject", _targetTruck player]",
    ""
];

 

I have also tried:

 

    "player action ["engineOff", _targetTruck]
     player action ["eject", _targetTruck]",

 

This is what I came up with so far. The error that returns is "missing ]". Any help with any of the code would be greatly appreciated!

  • Like 1

Share this post


Link to post
Share on other sites

Inside
 

 "player action ["engineOff", _targetTruck player]
     player action ["eject", _targetTruck player]",
    ""

replace the double quotes " by single quotes '
to get this
 

 _targetTruck = "rhsusf_M1078A1P2_B_D_CP_fmtv_usarmy" createVehicle _mark;

 

_returnTrig = createTrigger["EmptyDetector", _returnTrigPos];
_returnTrig setTriggerArea [5,5,0, false];
_returnTrig triggerAttachVehicle [_targetTruck];
_returnTrig setTriggerActivation ["VEHICLE", "PRESENT", true];
_returnTrig setTriggerStatements ["this",
    "player action ['engineOff', _targetTruck player]
     player action ['eject', _targetTruck player]",
    ""
]; 

 

  • Like 2

Share this post


Link to post
Share on other sites

Action: Eject

The example being:

_unit action ["Eject", _vehicle];

 

So _targetTruck player isn't returning a vehicle, it's trying to return a vehicle and player, which is incorrect. Either use:

 

_targetTruck

OR

vehicle player

 

The point above about the double and single quotes is also worth taking note of. 

 

  • Like 3

Share this post


Link to post
Share on other sites

Aswell as what @Mr H. says about quotes, _targetTruck is out of scope for the code in the trigger statement. Plus _targetTruck player make no sense anyway.

Either use triggerAttachedVehicle thisTrigger, or vehicle player or thisList select 0.

 

_targetTruck = "rhsusf_M1078A1P2_B_D_CP_fmtv_usarmy" createVehicle _mark;

_returnTrig = createTrigger["EmptyDetector", _returnTrigPos];
_returnTrig setTriggerArea [5,5,0, false];
_returnTrig triggerAttachVehicle [_targetTruck];
_returnTrig setTriggerActivation ["VEHICLE", "PRESENT", true];
_returnTrig setTriggerStatements ["this",
    "player action ['engineOff', triggerAttachedVehicle thisTrigger]
     player action ['eject', triggerAttachedVehicle thisTrigger]",
    ""
]; 

 

  • Like 5

Share this post


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

Upon entering trigger area I'm trying to cut engine and eject the player from the _targetTruck.

 

 

_targetTruck = "rhsusf_M1078A1P2_B_D_CP_fmtv_usarmy" createVehicle _mark;

 

_returnTrig = createTrigger["EmptyDetector", _returnTrigPos];
_returnTrig setTriggerArea [5,5,0, false];
_returnTrig triggerAttachVehicle [_targetTruck];
_returnTrig setTriggerActivation ["VEHICLE", "PRESENT", true];
_returnTrig setTriggerStatements ["this",
    "player action ["engineOff", _targetTruck player]
     player action ["eject", _targetTruck player]",
    ""
];

 

Not sure to understand the aim of this trigger, even with @Larrow  version.  If the player is on board, he ejects. If not, but inside the trigger area, he cuts the engine off (if on)....  Is it something to lock the vehicle? So, there is a better way for that.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks all for the replies!

My plan is for the player to drive into the trigger area and be ejected, the truck to be deleted and then addscore to the player as a currency. I'm pretty new to scripting so I figured it was something simple. I don't know why I used _targetTruck player :tounge_o:.

I have made the changes you all graciously suggested :

 

_targetTruck = "rhsusf_M1078A1P2_B_D_CP_fmtv_usarmy" createVehicle _mark;

_returnTrig = createTrigger["EmptyDetector", _returnTrigPos];
_returnTrig setTriggerArea [5,5,0, false];
_returnTrig triggerAttachVehicle [_targetTruck];
_returnTrig setTriggerActivation ["VEHICLE", "PRESENT", true];
_returnTrig setTriggerStatements ["this",
    "player action ['engineOff', triggerAttachedVehicle thisTrigger]
     player action ['eject', triggerAttachedVehicle thisTrigger]",
    ""
];

 

I also tried adding hint 'Return Truck', In the hopes of getting some kind of response. 

But unfortunately nothing happens inside the trigger area. No more errors though!!

 

Share this post


Link to post
Share on other sites

Your code will not work anyway.

Why do you attach the trigger to the vehicle? It seems to me, your vehicle must enter a wider static area, then player is ejected.

Share this post


Link to post
Share on other sites

The trigger does not recognize the vehicle if I don't attach them. The code worked with hint 'Return Truck', before I tried adding the player actions.

Share this post


Link to post
Share on other sites

trigger anyPlayer present , area what you want 50m x 50 m for example, repeatable or not. So trigger is static. If you need something to lock the seat, you don't need a trigger.

 

cond : this

 

on act:  { if (!isNull objectParent driver _x) then { driver _x action ["engineOff", objectParent driver _x]; driver _x action ["eject",objectParent driver _x]} } forEach thisList;

 

So, objectParent returns the vehicle if player is a vehicle or objNull if on foot. In the case of the trigger, you need to specify driver because the trigger's list doesn't make difference between the player and his vehicle.

Player MUST drive inside the trigger area to be ejected.

Note: For MP and several vehicles, there is something to do for rearming the trigger.

 

Hope this help.

  • Like 2

Share this post


Link to post
Share on other sites
11 hours ago, FullyAutoJuiceBox said:

But unfortunately nothing happens inside the trigger area. No more errors though!!

Works fine for me. As a test place down a vehicle, place a player nearby.

In the vehicles init place..

this addEventHandler [ "GetIn", {
	params[ "_vehicle", "_position" ];
	
	if ( _position == "Driver" ) then {
		_trg = createTrigger [ "EmptyDetector", _vehicle getPos[ 15, getDir _vehicle ], false ];
		_trg setTriggerArea [ 5, 5, 0, false ];
		_trg triggerAttachVehicle [ _vehicle ];
		_trg setTriggerActivation [ "VEHICLE", "PRESENT", true ];
		_trg setTriggerStatements ["this", "
			player action[ 'Eject', triggerAttachedVehicle thisTrigger ];
		", ""];		
	};
}];

Press preview, climb in vehicle as driver, drive forward and get ejected when you hit the trigger.

  • Like 2

Share this post


Link to post
Share on other sites

Just going back to the older post aren't we missing  between the player actions

 

_returnTrig setTriggerStatements ["this",
    "player action ['engineOff', triggerAttachedVehicle thisTrigger]  < here
     player action ['eject', triggerAttachedVehicle thisTrigger]",
    ""
];

 

Even if it does work won't it just eject you from the vehicle as soon as the trigger is created.

  • Like 3

Share this post


Link to post
Share on other sites

I finally got to test these out after a couple busy days. I got both codes to work very easily!

 

But this code was best implemented in the script I had so far.

On ‎9‎/‎7‎/‎2018 at 8:55 PM, pierremgi said:

{ if (!isNull objectParent driver _x) then { driver _x action ["engineOff", objectParent driver _x]; driver _x action ["eject",objectParent driver _x]} } forEach thisList;

 

This is how it looked in the end for anyone looking for a quick answer.

 

_trg = createTrigger [ "EmptyDetector", _mark1];
_trg setTriggerArea [ 5, 5, 0, false ];
_trg setTriggerActivation [ "ANYPLAYER", "PRESENT", true ];
_trg setTriggerStatements ["this",
    "{ if (!isNull objectParent player) then { player action ['engineOff', objectParent player]; player action ['eject',objectParent player]} } forEach thisList;",
    ""];

 

 

Also wanted to say @Larrow  @pierremgi, thanks for all your posts through the forums. Everywhere I look I see you guys contributing. It's really appreciated!

 

 

 

 

 

  • 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

×