Home   Help Search Login Register  

Author Topic: Using createunit to refill a group  (Read 444 times)

0 Members and 1 Guest are viewing this topic.

eurostorm

  • Guest
Using createunit to refill a group
« on: 29 Jun 2003, 03:21:32 »
Okay, I'm new to OFP editing so don't bite me  :o

I've been making my first mission for the last week or so and thanks to this website I've been able to figure everything out without making one post. But now I'm stuck :( I've searched the forums and tutes and everything but I can't fix it so here goes.

I'm trying to make a script that will createunit exactly enough units to refill your group. They'll be created at an objective via a trigger and will join you, but that won't give me any problems. The problem is my infinite loop.

Here's how I structured it:

Create an array of my group.
Count the number of units in my group.
Subtract the number of units in my group from 12.
Create the difference.

No error messages, and the units DO spawn and join, but my hint to let me know the loop has run continues forever, so I'm guessing there is something wrong with my count variable? I just need to it stop once the number of units needed to fill have been created. I dunno.

Now I'm still pretty new to scripting to there may be a glaring error I'm just missing, but any help is greatly appreciated!

Thanks.

Code: [Select]

;Intention is to count the number of units in your group, then spawn exactly enough to refill the group..

_mygroup = russianops
_listunits = units _mygroup
_total = count _listunits
_spawnnum = (12 - _total)
?_spawnnum =0: goto "end"
_count= 0

#loop

~1

?_count=_spawnnum : goto "end"

_count=_count+1

"uce_rusomonSoldier" createunit [getmarkerpos "hello",russianops,"",0.8]

hint "Running Script"

goto "loop"

#end
exit
« Last Edit: 29 Jun 2003, 04:05:07 by eurostorm »

peter

  • Guest
Re:Using createunit to refill a group
« Reply #1 on: 29 Jun 2003, 04:14:08 »
? _count == _spawnnum : goto "end"  ;)
« Last Edit: 29 Jun 2003, 04:15:24 by peter »