Home   Help Search Login Register  

Author Topic: setunitpos for whole squad  (Read 1476 times)

0 Members and 1 Guest are viewing this topic.

ThEoNeAnDoNlY

  • Guest
setunitpos for whole squad
« on: 23 Apr 2005, 00:15:49 »
hey, can someone please tell me how to make everyone in a squad follow the *this setunitpos "up"* command.

the only way i have found to do it is to write it in each persons individual init line which can be very tedious, so is there a way i can call it for the whole squad

Quote
e.g. "_x setunitpos "up"" foreach units group this

ofcourse i know that would not work but atleast you now know what im trying to achieve.

thanx

Guy

Offline Pilot

  • Contributing Member
  • **
Re:setunitpos for whole squad
« Reply #1 on: 23 Apr 2005, 00:19:30 »
Try this

{_x setunitpos "UP"} foreach units group this
« Last Edit: 23 Apr 2005, 00:19:50 by Student Pilot »

Offline nigel

  • Members
  • *
  • I'm a llama!
Re:setunitpos for whole squad
« Reply #2 on: 23 Apr 2005, 05:14:53 »
Try this

{_x setunitpos "UP"} foreach units group this

I might be wrong... but I think the quotes have to be in a certain spot for that command.. i.e. "_x setunitpos {up}" foreach units group this


Offline Peter_Bullet

  • Members
  • *
  • "The evil that men do lives on and on"
Re:setunitpos for whole squad
« Reply #3 on: 23 Apr 2005, 06:26:48 »
Try this

{_x setunitpos "UP"} foreach units group this

I've used this many times and it has always worked.

ThEoNeAnDoNlY

  • Guest
Re:setunitpos for whole squad
« Reply #4 on: 23 Apr 2005, 18:53:36 »
ok thanx guys!

anyone wanna tell me exactly why it had to be laid outin such a way? im keen to learn!

Guy

Offline Peter_Bullet

  • Members
  • *
  • "The evil that men do lives on and on"
Re:setunitpos for whole squad
« Reply #5 on: 25 Apr 2005, 18:10:01 »
It is a command excecuted to every element in a given array where _x is the current element

like this {_x setDamage 1} forEach [s1,s2,s3,s4]
first time _x is s1 > it sets him dead, then s2 and then s3....
(you can also do like this) {_x setUnitPos "Up"; _x setDamage 1; _x something}

units group this: Units lists an array (list) of the men in a given group; group this returns the group where unit "this" is in....

I hope you understood, I'm not too good explaining these...  :-[

ThEoNeAnDoNlY

  • Guest
Re:setunitpos for whole squad
« Reply #6 on: 25 Apr 2005, 21:56:10 »
no no, that was a good explanation dont worry!

i understand now, i think it is important to know why these commands work and on posts such as this it is good to give explanations so that other people can learn.

thanx!

Guy

Dubieman

  • Guest
Re:setunitpos for whole squad
« Reply #7 on: 26 Apr 2005, 02:35:29 »
You sort of confused me there Epeli, but I got it. It just a command being applied to a whole group. Anyways, solve it if your done with it. ;)

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:setunitpos for whole squad
« Reply #8 on: 27 Apr 2005, 07:57:25 »
I might be wrong... but I think the quotes have to be in a certain spot for that command.. i.e. "_x setunitpos {up}" foreach units group this

These are all valid lines that will work in that situation:

"_x setunitpos {up}" foreach units group this
{_x setunitpos "up"} foreach units group this
"_x setunitpos ""up""" foreach units group this

OFP differentiates between {}, "" and "" "".
Believe it or not you can string multiple nested quotes within one another using the right combination of quotes.

(Stop reading now if you don't want to be really confused)

I often use a trigger to activate a script command by passing it a string. the string ends up looking something like this:

string = """_x setbehaviour {aware}"" foreach [alpha, bravo, charlie]"

Which will work fine, provided you don't miscount the quotes ;)