Home   Help Search Login Register  


Author Topic: Trigger  (Read 1431 times)

0 Members and 1 Guest are viewing this topic.

Offline Bontz07

  • Members
  • *
« on: 20 Dec 2012, 17:31:53 »

Im wondering how to make trigger be activated, when unit goes inside a trigger, and when he is out range, the trigger unactivates. And this should be done all the time; unit in, unit out -> trigger act., trigger unact.

What's all about this? I wan't player to have a new action when he's inside certain area. If he leaves it, action will disappear. Action only works inside the trigger. Could there be any other way to carry out this script? Mayby distance command?...

E: Also, what would be the easiest or simplest way to remove action, when it is used once?
« Last Edit: 20 Dec 2012, 17:41:01 by Bontz07 »

Offline savedbygrace

  • Mission Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: Trigger
« Reply #1 on: 21 Dec 2012, 04:04:34 »
What's up pal?!
Just to settle my own curiosity; are you truly building a project in Arma or did you mean to post this in Arma 2? There is no difference to be honest, I was just wondering if there was still activity in Arma.

Anyhow, the answers....

To have an individual unit activate a trigger exclusively, you must group him to the trigger. Select F2(GROUPS)>>left click on the trigger and hold>> slide mouse over individual unit and release button. That makes it so that only that unit will activate the trigger.

Code: [Select]
SBG_ActionVariable = player addaction ["Activate Switch","toggleswitch.sqs"]
Assigning a global variable to an addaction will allow you to access that action anywhere within the mission, whether it's another trigger, waypoint, script or even the init of a spawned object.

The code above demonstrates the assignment of the global variable "SBG_ActionVariable" to the addaction that follows. "player" of course, is the universal reserved global variable for the player unit, so you will never need to assign another global variable to the player unit; just use "player". The rest of that code can be identified by reading the command for it in the COMREF.

To remove that action from anywhere in the mission you utilize the removeaction command. In this case, it would be...
player RemoveAction SBG_ActionVariable

It's important to note that when you begin to use global variables, you have the potential of interfering with global variables used in the game code itself or addons. To avoid this headache of conflict, Sign up for a free tag here and prefix it to all of your Global variables from this point forward.

Now, if you would like to use this in a trigger, simply insert the AddAction into the OnActivation field of the trigger.
Then insert the RemoveAction into the Deactivation field.

If you want the trigger to always give the option to activate the action without allowing the player to activate it more than once, you will have to assign a global variable the the trigger itself and then delete it once the script is executed.

Or you could just add the action to an object and remove the action or delete the object within the script.

It would also be worth your time to read some tutorials, sift through the editing boards and play other user made missions to see how they have done things.

Happy editing buddy.