Forum Jump :

Author Message


Posts: 6
Rank:


Level: Member

Country: cz
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2013-08-14 13:09        
     
Do you know how to please someone randomly choose one soldier from the group (grp1)?
Note: The selection not to be a vehicle.
Thank you in advance.


Author Message


Posts: 426
Rank:


Level: Member

Country: it
Location: In ArmA edit when I can
Occupation: Security officer
Age: 47
In-game name: maxjoiner

 
#2 Posted at 2013-08-14 14:03        
     
In ArmA editor Insert into Init line of group leader this:

Grp1 = group this;

then use this in script:

_group_array = units Grp1;

_Unit = _group_array select (round (random ((count _group_array) - 1)));



_Unit is the random soldier of Grp1


Advertisement


Author Message


Posts: 6
Rank:


Level: Member

Country: cz
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2013-08-14 15:19        
     
And how is it resolved that the unit is not the vehicle that may be a member of?
Thanks


Author Message


Posts: 426
Rank:


Level: Member

Country: it
Location: In ArmA edit when I can
Occupation: Security officer
Age: 47
In-game name: maxjoiner

 
#4 Posted at 2013-08-14 19:38        
     
In editor named the vehicle group like: Vehicle1

then add some line to my script:

_driversoldier = (driver Vehicle1);

_group_array = units Grp1;

_Unit = _group_array select (round (random ((count _group_array) - 1)));

if (_unit == _driversoldier) exitwith {execVM "randomsoldier.sqf"};
// if the soldier random is the driver vehicle repeat the script

_Unit is the random soldier of Grp1 but not the vehicle


Author Message


Posts: 6
Rank:


Level: Member

Country: cz
Location:
Occupation:
Age:
In-game name:

 
#5 Posted at 2013-08-15 09:53        
     
Works! Thanks a lot Maxjoiner!


Author Message


Posts: 426
Rank:


Level: Member

Country: it
Location: In ArmA edit when I can
Occupation: Security officer
Age: 47
In-game name: maxjoiner

 
#6 Posted at 2013-08-15 11:15        
     
No problem