OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Blanco on 06 Feb 2005, 03:10:30

Title: what's wrong with this?
Post by: Blanco on 06 Feb 2005, 03:10:30
I have a group with 3 West soldiers (I'm the leader) and 2 dogs.
I want an array with all the dogs, that's all.

I got this :

Code: [Select]
_group = _this select 0

_dogs = []

"if (typeof _x == "TCP_TestDog") then {[_dogs = _dogs + [_x]}" foreach Units _group

hint format ["%1",_dogs]

The error is unknown operator TCP_testdog...

What's wrong with it?
Title: Re:what's wrong with this?
Post by: Fragorl on 06 Feb 2005, 05:09:32
Possibly the problem is that you missed out a semicolon and included an extra bracket:

"if (typeof _x == "TCP_TestDog") then {_dogs = _dogs + [_x]};"
instead of
if (typeof _x == "TCP_TestDog") then {[_dogs = _dogs + [_x]}

Other than that it looks fine...
Title: Re:what's wrong with this?
Post by: Blanco on 06 Feb 2005, 05:21:04
Nhaa,
You were right about that bracket but I dunno why I need that semicolon. Thanks anyway, but the same error shows up.
Title: Re:what's wrong with this?
Post by: macguba on 06 Feb 2005, 11:48:15
Have you checked that TCP_TestDog is absolutely correct?    It's a string so you need the case right.
Title: Re:what's wrong with this?
Post by: h- on 06 Feb 2005, 12:05:22
@macca
That won't give an unknown operator error, that would give 'type this expected that' or something similar...


@Blanco:
Try this

Code: [Select]
"if (typeof _x == ""TCP_TestDog"") then {[_dogs = _dogs + [_x]}" foreach Units _group
or


Code: [Select]
{if (typeof _x == "TCP_TestDog") then {[_dogs = _dogs + [_x]}} foreach Units _group
EDIT:
If that's an *sqf you will need the semicolon at the very end of each line...
Title: Re:what's wrong with this?
Post by: Blanco on 06 Feb 2005, 13:25:38
Solved.

Quote
{if (typeof _x == "TCP_TestDog") then {_dogs = _dogs + [_x]}} foreach units _group

It works.
THX.  :)