Jump to content
sekurlsa

Trying to understand how triggers work in multiplayer.

Recommended Posts

I have a trigger, the trigger is set to Activation: blufor, it is also repeatable.

On activation I have:
varvar setDamage 1;

 

varvar is a playable character. 

 

When the "playable" character enters the trigger area, as expected, character dies, but after respawn the trigger no longer works.

How should I refer to the character activating the trigger? 

Share this post


Link to post
Share on other sites

As far as I remember, when you respawn, varvar is still pointing to your first (dead) character and not your current (alive) character.

 

If you want to target the current player character, use https://community.bistudio.com/wiki/player

However if you have something more complicated in mind, i.e. you want to carry information from the dead character to the respawned one, you can use https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#MPRespawn

  • Like 1

Share this post


Link to post
Share on other sites

Okay, I get it, like below it will get the job done, i've tested it. 

But what If I want to perform a check about an equipped item for instance, it still fails although I'm now referring to the proper player object.

Any suggestions how to get this to work?

params ["_unit"];
if ("G_Balaclava_blk" in goggles _unit) then
{
	hint "Balaclava is equipped";
};

 

 

 

// Working example with setDamage 1;
Character init:

[this] execVM "unit_init.sqf"


unit_init.sqf:

private ["_unit"];

_unit = _this select 0;

fnc_overlay = compile preprocessFileLineNumbers "damage.sqf";

fnc_overlayInit =
{
private ["_unit"];

_unit = _this select 0;

_unit spawn fnc_overlay;
};

_unit addEventHandler ["Respawn",
{
[_this select 0] call fnc_overlayInit;
}];

damage.sqf

params ["_unit"];
_unit setDamage 1;

 

Share this post


Link to post
Share on other sites
6 hours ago, sekurlsa said:

Any suggestions how to get this to work?


params ["_unit"];
if ("G_Balaclava_blk" in goggles _unit) then
{
	hint "Balaclava is equipped";
};

 

You wanna do "G_Balaclava_blk" isEqualTo goggles _unit

  • Like 1

Share this post


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

You wanna do "G_Balaclava_blk" isEqualTo goggles _unit

Nothing happens. :sad:
I'm really lost, setDamage works, but this doesn't. What I get from this _unit is correctly pointing to the player in scope.
hint str(goggles _unit); returns G_Balaclava_blk so this is correct as well but the if statement is not firing. 
Edit: Further to my last, hint str([_unit, "G_Balaclava_blk"] call BIS_fnc_hasItem); equals false. so there is that - at least everything is failing.

Share this post


Link to post
Share on other sites
On 3/15/2022 at 7:11 PM, sekurlsa said:

How should I refer to the character activating the trigger? 

Attach them to it (triggerAttachVehicle), and use triggerAttachedVehicle to reference them.

As most trigger commands are EL you can override editor placed triggers independently on each client.

//initPlayerLocal.sqf
params[ "_player" ]

_theTrigger = SomeNameGivenToTriggerInEditor;

_theTrigger setTriggerActivation[ "VEHICLE", "PRESENT", true ];
_theTrigger triggerAttachVehicle[ _player ];

_theTrigger setTriggerStatements[ "this", "hint format[ '%1 entered the trigger', name triggerAttachedVehicle thisTrigger ]", "" ];

 

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, Larrow said:

Attach them to it (triggerAttachVehicle), and use triggerAttachedVehicle to reference them.

As most trigger commands are EL you can override editor placed triggers independently on each client.


//initPlayerLocal.sqf
params[ "_player" ]

_theTrigger = SomeNameGivenToTriggerInEditor;

_theTrigger setTriggerActivation[ "VEHICLE", "PRESENT", true ];
_theTrigger triggerAttachVehicle[ _player ];

_theTrigger setTriggerStatements[ "this", "hint format[ '%1 entered the trigger', name triggerAttachedVehicle thisTrigger ]", "" ];

 

Amazing, thanks!

 

Share this post


Link to post
Share on other sites

Further on this topic:

This generally and Larrow's reply answer my questions.

Thanks to everybody for the assist!

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

×