Home   Help Search Login Register  

Author Topic: join and lead a group via script  (Read 979 times)

0 Members and 1 Guest are viewing this topic.

wastzzz

  • Guest
join and lead a group via script
« on: 07 Sep 2006, 13:43:42 »
As subject.. I need a script that, when it gets triggered, makes unit1 to join and lead grp1.
I already tried with: "[_x] join unit1" foreach units grp1 (which is the reverse), and basically it works, but then a lot of radio messages are being sent by each unit of the new group and I don't want that.

thanks in advance
wasti.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: join and lead a group via script
« Reply #1 on: 07 Sep 2006, 13:54:37 »
combine it with the enableradio command. it's the only way to stop them reporting to you as they join the squad.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: join and lead a group via script
« Reply #2 on: 07 Sep 2006, 13:56:27 »
Maybe you can disable the radio messages beforehand and re-enable them afterwards.

Check the Command Reference.

Specifically enableRadio.


Planck
I know a little about a lot, and a lot about a little.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: join and lead a group via script
« Reply #3 on: 07 Sep 2006, 14:35:23 »
It all depends on which waypoints you want the new group to follow.  If you really want unit1 to join and lead grp1, ie using grp1's waypoints then you need something like:

Code: [Select]
_grp1Units = units grp1
[unit1] join grp1
_grp1Units join grpNull
_grp1Units join unit1

The way this works is that unti1 joins grp1, then each of the original members are moved out of the group and then moved back again.  This will ensure that unit1 is then the leader and the original waypoints are retained.  Also as mentioned above turn the radio off to stop the messages.

I see two isses with:
Quote
"[_x] join unit1" foreach units grp1


1. the use of " " to delineate code - it works for OFP but might not work later.  Better to use " " for strings and { } for code to become furture ready.
2. join requires an array.  Your instruction above gives it an array one element at a time - why not give it the whole array in one go?

So if you are happy that what you have does what you want I would encourage you to re-write it as:

Code: [Select]
units grp1 join unit1
Simpler?
« Last Edit: 07 Sep 2006, 21:13:06 by THobson »

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re: join and lead a group via script
« Reply #4 on: 09 Sep 2006, 00:24:48 »
To shut off the radio chatter "ready" for each unit joining do this:

Code: [Select]
enableRadio false
_delay = (count units grp1) * 1.2
units grp1 join unit1
~ _delay
enableRadio true

This regulates how long the radio stays turned off. The more units you have, the longer is must stay off.  You may have to adjust the 1.2. If the last few guys can still be heard saying "ready" then try 1.3 or 1.4. You may want to hear the final guy say "ready".