Forum Jump :

Author Message

zmith  



Posts: 1
Rank:


Level: Member

Country: af
Location: Afghanistan
Occupation: Developer
Age: 34
In-game name:

 
#1 Posted at 2010-11-30 07:34        
     
Hi Gents

I am hoping someone can help me with this one:

I am busy creating a mission in which I have a single East group (Opfor East). During the progress of the mission I am adding and removing units dynamically (side east). I am looking for a way that I can add to this group and get a handle to the last unit that I have just added. I make use of createunit script command and there are two versions:

Version 1: createUnit
http://community.bistudio.com/wiki/createUnit
This version does not return a handle to the unit that was added. You have to either search the unit array of the group and this is not optional in my case since the group changes constantly. I noticed that you can also do something like: _member = (units _grp) select ((count units _grp) – 1) in which case u assume the last added unit is the last member added but in my case this also does not work.

Version 2: createUnit array
http://community.bistudio.com/wiki/createUnit_array
This command seemed perfect since the command returns a unit that was added to the group. Works wonders and gives me what I want eg:

_unit = _grp createUnit ["SoldierWB", Position player, [], 0, "FORM"] (_grp is side EAST group)

The issue with this script command is that when I add a unit in which the unit type is inherently side GUER the side of that unit in the group is side “GUER” and does not take on the side of what the group is in this case I want it to be side EAST. So this command does not work to cool either. If there was a command to change the side of a unit it would be great but there is not!

I tried setting global variable in the unit init string on create e.g “LOON1 = this” and then reference this variable but it does not work when u are spawning mass units.

Can someone maybe think if a way that I can get this right? Maybe something I am doing wrong?

Thanks

Added 23 hours 8 minutes later:

Something I tried that seems to work:

I created a temporary east group _tmpGrp and then use createunit (1 unit in the group) I then added that unit to the group I initially wanted to add it to. Something like this:

_tmpGrp = creategroup east;
"SoldierWB" createUnit [position player, _tmpGrp];
_member = (units _tmpGrp) select 0;
[_member] join WorldEastGroup ; // WorldEastGroup is a global east group
deletegroup _tmpGrp;

This is not ideal but this seems to work but not that elegant. I will use it until I find something better. If anyone has better idea please let me know.

This post was edited by zmith (2010-12-01 07:15, ago)

zmith - ArmA FTW!!!
http://www.armaholic.com





Tags: Createunit