Jump to content
Sign in to follow this  
snkman

How to get leader of a group in a script

Recommended Posts

Hey guy's,

well i have a script called with:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[ge1,[ge2,ge3],[gw1]] exec "myScript.sqs"

ge1,ge2,ge2 and gw1 are groups

Now in myScript.sqs i have:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0

_friends = _this select 1

_enemys = _this select 2

But "myScript.sqs" only allows units to pick the leader of the groups so i need a way to split all thous groups into units again or select the leader of the groups "ge1,ge2,ge3 and gw1"

How can i do this?

I tryed with:

myScript.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0

_friends = _this select 1

_enemys = _this select 2

_unit = unit select 0

_friend = _friends select0

_enemys = _enemys select 0

and

myScript.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0

_friends = _this select 1

_enemys = _this select 2

_unit = unit in units group _unit

_friend = _friends in units group _friends

_enemys = _enemys in units group _enemys

But it didn't work... sad_o.gif

Someone knows a solution for this?

Share this post


Link to post
Share on other sites

Yes i have and it works but only with the first group "ge1"

So if i have:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[ge1,[ge2,ge3],[gw1]] exec "myScript.sqs"

and in the script:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0

_friends = _this select 1

_enemys = _this select 2

_unit = leader _unit

_friends = leader _friends

_enemys = leader _enemys

And i make a debug with: titletext[format ["\n\n\n %1 ",_unit], "Plain down"]

the leader of the group is shown ( EAST 1-1A:1 )

But if i make a debug with the _friends i only get the whole groups ( EAST 1-1B, EAST 1-1C )

same to _enemys ( WEST 1-1A )

Share this post


Link to post
Share on other sites

This problem appears because you have not gone deep enough into your array. You have nested arrays so you must do more select commands to pick the groups from the subarrays.

If you have an array: [ge1,[ge2,ge3],[gw1]] passed to the script, then you could get the leader of ge1 by doing: leader (_this select 0)

to get the leader of ge2 you will need to do: leader ((_this select 1) select 0)

and so on.

Study more about arrays.

Share this post


Link to post
Share on other sites

Pretty nice Baddo wink_o.gif

Finally the script starts working correctly without error messages. smile_o.gif

The way i choosed is a little bit strange but anyway it works so it should be okay till i found a better ont

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0

_friends = _this select 1

_enemys = _this select 2

_array1 = leader ((_this select 1) select 0)

_array2 = leader ((_this select 1) select 1)

_unit = leader _unit

_friends = [_array1,_array2]

_enemys = leader player

THX Baddo

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  

×