Home   Help Search Login Register  

Advertisement

Author Topic: Join my group by distance.  (Read 1492 times)

0 Members and 1 Guest are viewing this topic.

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Join my group by distance.
« on: 18 Jan 2017, 01:31:48 »
Ok, didn't want to ask in here as the forum is cold and fairly lifeless. However, I can't find the right wording anywhere that gets me close to a simple querie.

I have an addaction. When the player clicks it, I want anyone within 20m to join the player's group. Should be simple but I can't do it.

Any help appreciated.
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline SoldierEPilot

  • Members
  • *
Re: Join my group by distance.
« Reply #1 on: 19 Jan 2017, 10:31:49 »
init.sqf
Code: [Select]
ALLY=[];
{
if (side _x==side player) then {ALLY set [count ALLY, _x]};
} forEach allUnits;
PR=rating player;
player addAction ["Join units", "join.sqf"];

join.sqf
join.sqf
Code: [Select]
private "_ct";
_ct=count units player;
{
if ((alive _x) && (_x distance player<20) && (_ct<12) && (PR>rating _x)) then
{
[_x] join player;
_ct=_ct+1;
}
} forEach (ALLY-units player);

One can remove "PR>rating _x" fragment
to join units despite of their ranks.


Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Join my group by distance.
« Reply #2 on: 20 Jan 2017, 11:47:51 »
Or, simplier (you didn't specify if ranks matter so left it out).
You can paste this into a trigger on activation if you wish (just remove the comments first), or in some script (like init.sqf if you wish it to be available right from the start):
Code: [Select]
player addAction [
"Join Me", //title of the action
{
(_this select 0) removeAction (_this select 2);//removes the action once used,

// finds man class objects around the player within 20m radius and if on the same side as player joins them silently (without the radio calls)
{
if (side _x == side player) then {
[_x] joinSilent player;
};
} forEach (nearestObjects [player, ["Man"], 20]);
}
];

EDIT:
Didn't test the above in A1 though, so not 100% it will work :P

EDIT2:
Oh, and in case you weren't already familiar with A1 scripting, it prefers .sqf not .sqs so any script examples we give are in .sqf format (both scripts and functions are now in .sqf) and such scripts have to executed using execVM, not exec.
Just wanted to make sure, not knowing how familiar you are with these thingies...  :dunno:
« Last Edit: 20 Jan 2017, 12:02:43 by h- »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: Join my group by distance.
« Reply #3 on: 25 Jan 2017, 02:22:09 »
Thanks for that guys. Much appreciated.

I've been throwing .sqs and .sqf files into my missions. Behind the scenes they look like Frankenstein's monster but they play really well. I've taken script snippets and full blown scripts from everywhere. I plan to release a campaign soon. I don't mind if only a handful of people play it. I've enjoyed the journey.
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline savedbygrace

  • Mission Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: Join my group by distance.
« Reply #4 on: 25 Jan 2017, 04:56:28 »
Ah crap, you mean I have to play Armed Assault again? The torture!!  :whistle:

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Join my group by distance.
« Reply #5 on: 27 Jan 2017, 23:31:45 »
@SBG, you heathen, you must always have All The Games installed and ready to play :P
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline savedbygrace

  • Mission Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: Join my group by distance.
« Reply #6 on: 28 Jan 2017, 03:55:50 »
Yes, yes. I remember that thread well boss. I'll be ready.

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: Join my group by distance.
« Reply #7 on: 03 Feb 2017, 00:55:52 »
savedbygrace, I'm using some sound files from Fly Like an Eagle. Is that ok?
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline savedbygrace

  • Mission Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: Join my group by distance.
« Reply #8 on: 05 Feb 2017, 05:16:44 »
Of course it is.