Jump to content
Coladebote

Activate Three scripts per trigger at different times

Recommended Posts

Hi guys:
In a multiplayer mission I want to use a single trigger (TRIGGER_1) to start three scripts at different times. The first script (script_1) is triggered by any player when they enter the trigger area, which in this case is 800 meters. No problem so far:

 

[] spawn {execVM "scripts\scripts_1.sqf";}

 

The second script (script_2) has to be activated when any player is within 50 meters of the trigger. The third script (script_3), should start when a player is 10 meters from the trigger.

Can someone help me to solve the problem, thanks.

Share this post


Link to post
Share on other sites

@Coladebote, trigger condition:

(this and { !(thisTrigger getVariable ["script1Started", false]) }) or { ((player distance thisTrigger) < 50) and { !(thisTrigger getVariable ["script2Started", false]) } } or { ((player distance thisTrigger) < 10) and { !(thisTrigger getVariable ["script3Started", false]) } }

on activation:

if (!(thisTrigger getVariable ["script1Started", false])) then {
    execVM "scripts\scripts_1.sqf";

    thisTrigger setVariable ["script1Started", true];
};
if (((player distance thisTrigger) < 50) and { !(thisTrigger getVariable ["script2Started", false]) }) then {
    execVM "scripts\scripts_2.sqf";

    thisTrigger setVariable ["script2Started", true];
};
if (((player distance thisTrigger) < 10) and { !(thisTrigger getVariable ["script3Started", false]) }) then {
    execVM "scripts\scripts_3.sqf";

    thisTrigger setVariable ["script3Started", true];
};

Seems that creating 3 triggers can be simpler.

  • Thanks 1

Share this post


Link to post
Share on other sites

Creating three triggers is simpler, but when it comes to mounting a target in each village in Altis, we are talking about 3 triggers x 35 villages. It is better to reduce.

Thank you for your contribution, tonight I will try it and I will tell you. It will go well for sure.

Share this post


Link to post
Share on other sites
38 minutes ago, Coladebote said:

Creating three triggers is simpler, but when it comes to mounting a target in each village in Altis, we are talking about 3 triggers x 35 villages.

You can create 35 markers and the script, that creates 105 triggers.

 

Also, I missed that your trigger is activated by any player, so here is updated version:

- trigger condition:

(this and { !(thisTrigger getVariable ["script1Started", false]) }) or {
    _unit = thisList select 0;

    (((_unit distance thisTrigger) < 50) and { !(thisTrigger getVariable ["script2Started", false]) }) or {
        ((_unit distance thisTrigger) < 10) and { !(thisTrigger getVariable ["script3Started", false]) }
    }
}

- on activation:

if (!(thisTrigger getVariable ["script1Started", false])) then {
    execVM "scripts\scripts_1.sqf";

    thisTrigger setVariable ["script1Started", true];
};

call {
    _unit = thisList select 0;

    if (((_unit distance thisTrigger) < 50) and { !(thisTrigger getVariable ["script2Started", false]) }) then {
        execVM "scripts\scripts_2.sqf";

        thisTrigger setVariable ["script2Started", true];
    };
    if (((_unit distance thisTrigger) < 10) and { !(thisTrigger getVariable ["script3Started", false]) }) then {
        execVM "scripts\scripts_3.sqf";

        thisTrigger setVariable ["script3Started", true];
    };
};

 

Share this post


Link to post
Share on other sites

The idea is magnificent, but for now I think it is something that exceeds me, I have to get on with it, try it.

Share this post


Link to post
Share on other sites

Keep it simple.
Activate your trigger with the farthest condition. Then spawn a code (or execVm an sqf) with some waitUntil condition for inner distances.

If you want to abort on deact (so when the player leaves the biggest area without closing the center),  just add a condition for :

<your distance cond>   or  !  triggerActivated yourTrig   in these waitUntil conditions. This way your code can continue when deact and you just need to add a following line with:  if (!triggerActivated yourTrig) exitWith {true}; in order to break the code. A solution among others.

  • Like 2
  • Thanks 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

×