Home   Help Search Login Register  

Author Topic: what's wrong with this?  (Read 674 times)

0 Members and 1 Guest are viewing this topic.

Offline Blanco

  • Former Staff
  • ****
what's wrong with this?
« 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?
Search or search or search before you ask.

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:what's wrong with this?
« Reply #1 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...
« Last Edit: 06 Feb 2005, 05:10:57 by Fragorl »

Offline Blanco

  • Former Staff
  • ****
Re:what's wrong with this?
« Reply #2 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.
« Last Edit: 06 Feb 2005, 13:21:15 by Blanco »
Search or search or search before you ask.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:what's wrong with this?
« Reply #3 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.
Plenty of reviewed ArmA missions for you to play

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:what's wrong with this?
« Reply #4 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...
« Last Edit: 06 Feb 2005, 12:08:03 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Blanco

  • Former Staff
  • ****
Re:what's wrong with this?
« Reply #5 on: 06 Feb 2005, 13:25:38 »
Solved.

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

It works.
THX.  :)


Search or search or search before you ask.