Home   Help Search Login Register  

Author Topic: Who activated the trigger?  (Read 3016 times)

0 Members and 1 Guest are viewing this topic.

Who activated the trigger?
« on: 01 Jul 2011, 22:13:41 »
I have a trigger which is activated when any member of the players group enters the trigger area which activates a script.

In the script I am trying to select the man who activated the trigger by using

Code: [Select]
_victim = _this select 0
But when I use _victim later in the script I get undefined variable in expression.

I've tried numerous different things none of which work.

Tried activating the trigger by using...

[this] exec
[thislist select 0] exec

And in the script instead of using _this select 0, I've tried

this select 0
thislist select 0
_thislist select 0

All of which don't seem to do anything.

I'm guessing it's probably fairly obvious why this isn't working but I just can't seem to get it to work

Edit - While I'm at it I've got another question...

I've got a set of objects labeled object1 all the way through to object 13, in a script I've tried to delete all this objects using

deletevehicle object1
deletevehicle object2

All the way to 13 except the script keeps telling me undefined variable in expression?
« Last Edit: 01 Jul 2011, 22:18:31 by aLlamaWithARifle »

Offline F2kSel

  • Members
  • *
Re: Who activated the trigger?
« Reply #1 on: 02 Jul 2011, 02:29:30 »
trigger
[thislist] exec "script.sqs"

script
_who = _this select 0
hint format["%1",_this] 

or

trigger
[thislist select 0] exec "script.sqs"
hint format["%1",_this] 

There are other ways.

Can't really say about the undefined variable, check spelling make sure all other syntax is correct as it can cause errors like this. What are you coding in sqf or sqs there are differences.

If I had 13 objects I'd put them in an array. In one of the units init put

objlist = [object1,object2 ect];

The when you want to delete them

{deletevehicle _x} foreach objlist;




Re: Who activated the trigger?
« Reply #2 on: 02 Jul 2011, 15:59:18 »
Thanks a lot, got the trigger working, gonna give the delete array a go and hope that works.

I seem to be having a lot of issues with undefined variables in ArmA 2 for some reasonm I'm scripting in .sqs still and using "? variablename : exit" doesn't seem to work, tells me it's an undefined variable. All I want to do is check if variablename is true, I've tried an _ as well but that doesn't seem to work.

Has ArmA 2 changed the way they use variables or something?

Offline F2kSel

  • Members
  • *
Re: Who activated the trigger?
« Reply #3 on: 02 Jul 2011, 17:25:55 »
They have changed some of the syntax, I don't script in sqs as it's hard to get as much help.



Taking this from an old script

Code: [Select]
? "alive _x" count units _grp == 0 : var=1
hint format["%1",var]
Result undefined variable.


Now

Code: [Select]
? (alive _x) count units _grp == 0 : var=1
hint format["%1",var]

result = 1

Offline Zipper5

  • BIS Team
  • ****
Re: Who activated the trigger?
« Reply #4 on: 02 Jul 2011, 19:08:18 »
Code: [Select]
? {alive _x} count units _grp == 0 : var=1
hint format["%1",var]
You must replace " in code like that with curly brackets. That is SQS code and will only work in SQS. If you wish to achieve the same result in SQF, use the following:
Code: [Select]
if ({alive _x} count units _grp == 0) then {var = 1};
hint format ["%1",var];
Keep in mind, _grp must be defined somewhere in that script too.