Jump to content
aie-boshell

Addaction for Player to Join AI Group within Radius - (Solved)

Recommended Posts

Hello, I'm looking to create an addaction on the players of dedicated servers which will allow them to join any AI's group that is within a certain radius of the player, lets say 50 meters.  I've tried with a big mess of attaching triggers to the player units with the addaction activating a script of "[player] join {_x} foreach thislist".  I thought that should work from what I've ready but no luck.  I may be totally lost with this and any help is much appreciated :-)  

Share this post


Link to post
Share on other sites

This script let the player join the group which leader is the nearest group leader within 50 meters (not tested):

_side = side player;
_radius = 50;
_radius_sqr = _radius ^ 2;

_side_groups_near = allGroups select { side _x isEqualTo _side and { leader _x distanceSqr player < _radius_sqr  and {alive leader _x}}} 
		    apply {[leader _x distanceSqr player, _x]};

if (count _side_groups_near isEqualTo 0) exitWith {false};

_side_groups_near sort true;

[player] join _side_groups_near select 0 select 1;

 

Share this post


Link to post
Share on other sites

Thanks so much for your help, sarogahtyp.  I was not able to get my feature working with that script but I did end up finding another way to get it done.  I first created a trigger it "jt" for join trigger.  I made it 50 meters circular radius and activation "Blufor Present".  I made it's condition True and checked "repeatable".  In activation I put "p addAction ["Join Unit", "joingroup.sqf"]"  where "p" is my player's unit name.  Then I placed one more trigger with the condition "true" and in activation I put "jt attachto[p,[0,0,0]]".  This will allow the 50 meter radius trigger to stay attached to me, the player, while I'm wondering throughout the world and the "joingroup.sqf" will cause me to join any unit in that 50 meter trigger radius.

 

joingroup.sqf consists of......

 

tlist = list jt;
{[p] join _x} foreach tlist;

 

 

 

And that's it.  Obviously, I would need to repeat the above for each playable unit I have within the server.  There's likely an easier way but for what it's worth, this one works flawless for me although I haven't yet tested on dedicated server.  Cheers :-)

 

 

Share this post


Link to post
Share on other sites

Sadly, this one has not done as expected on a dedicated server.  It appears as though "p addAction ["Join Unit", "joingroup.sqf"]" only gives the action to units around "p" and not to "p" itself on a dedicated server.  Which is weird because my player unit (p), has the action available when it's a single player mission, so I believe all I need to learn here now is how to create an addaction that stays with the player, in the action menu at all times on a dedicated server.  Any help is much appreciated :-)

Share this post


Link to post
Share on other sites

initPlayerLocal.sqf//Create that file in your mission folder.


 

(_this select 0) addAction//this select 0 is the player entity
[
    "Join Group",
    {hint "Works!"}
];

(_this select 0) addEventHandler
[
    "Respawn",
    {
        (_this select 0) addAction
        [
            "Join Group",
            {
                hint "Works"
            }
        ]
    }
];

 

 


 

  • Like 1

Share this post


Link to post
Share on other sites

This works and has helped me a ton.  Thank you so very much, R3VO :-)

  • Like 1

Share this post


Link to post
Share on other sites

My time is so short, and I feel like I should go into detail about how R3vo has helped me above, for those who end up at this post in the future, trying to use this info to help them.  I did have to tweak a few things to make it work with my mission and since R3vo helped me, I'm totally willing to help the next person get this information to work for them in any way I can.  It's just that every mission is different so I don't want to waste time explaining how I got this to work for my mission without more information on who I might help.  Sounds complicated and nerdy, but I promise I mean well, lol.  Thanks again, R3VO :-)

Share this post


Link to post
Share on other sites

one small tweak ... 

 

use playerSide instead of (side player). It is more reliably and consistent, as (side player) can sometimes report as "sideEnemy" or "sideFriendly" or "civilian" depending on situation (such as when needing revive, or when friendly fire has happened.

  • Like 2

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

×