Jump to content
Sign in to follow this  
Baron Hurlothrumbo IIX

Getting leader of mp group

Recommended Posts

Hi! Long time reader, first time poster hehe.

I have a problem - I want to have a script to put the leader of a squad in a boat as driver, in a MP game. I know what to put in - (whoever) moveindriver aBoat - but because this is a MP mission, the squad leader might not be the officer- he might have died. Half the squad might have died- but I still want the person in command of the squad to be the driver. Is there a way to get the leader? I know there should be, since you can group a trigger to only activate to the leader, but I dont know how.

thanks!

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">(leader groupname) moveindriver aboat<span id='postcolor'>

Should work.

RED

Share this post


Link to post
Share on other sites

D'oh! Thanks Red, I should have thought of that.

Umm... What about the second in command? (8 man squad, 6 cargo boat, 1 driver 1 gunner... ) - maybe I'll just make it a 7 man squad.

Share this post


Link to post
Share on other sites

a safer way to detect leader is to choose the zeroeth element of the group.

most of the time (leader myGroup) should equal (units myGroup select 0) but if the leader is renegade maybe or if he dies I'm not sure if the next unit will get the leader designation that works with (leader myGroup) - I don't think it works that way. If the leader dies the next element takes over but that element will now be the zeroeth unit in the group.

So, this answers your 2nd question. The 2nd in command will be (units myGroup select 1).

In addition to (moveindriver aboat) you should first assign the unit to the boat to avoid any issues of them being confused or unwilling to be in the vehicle without having been assigned.

_leader = units myGroup select 0

_leader assignasdriver aboat

_leader moveindriver aboat

To do a loop of all units in the group and do something with them (like move them all into a vehicle) you could do this:

_groupCount = count units myGroup

_vehicle = someVehicle

_unit = units myGroup select 0

_unit assignasdriver _vehicle

_unit moveindriver _vehicle

_count = 0

#top

_unit = units myGroup select _count

_unit assignascargo _vehicle

_unit moveincargo _vehicle

_count = _count + 1

?(_count < _groupCount):goto "top"

exit

if you want them to move on their own into the vehicle they'll get in after you give just the assignas commands.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×