OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started 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 :
_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?
-
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...
-
Nhaa,
You were right about that bracket but I dunno why I need that semicolon. Thanks anyway, but the same error shows up.
-
Have you checked that TCP_TestDog is absolutely correct? It's a string so you need the case right.
-
@macca
That won't give an unknown operator error, that would give 'type this expected that' or something similar...
@Blanco:
Try this
"if (typeof _x == ""TCP_TestDog"") then {[_dogs = _dogs + [_x]}" foreach Units _group
or
{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...
-
Solved.
{if (typeof _x == "TCP_TestDog") then {_dogs = _dogs + [_x]}} foreach units _group
It works.
THX. :)