ferstaberinde/F2 — pull request #36 by harakka (2012-11-21 18:10:23+00:00)
Title: Added an action menu option for joining other groups (closes #28)

Description:
This client-side script creates an infinite loop (with a 1s sleep to keep performance impact minimal) which checks for the following criteria:

* There is a leader of a different group, within ~2.5m radius of the player (about the same range as for opening a backpack).
* The group has playable units in it.
* Depending on a parameter player's side is also checked against the group's side.

If the criteria matches, an action is added to the player unit, which allows the player to join the group. The script then waits for the player to move away, with a grace period of 3 seconds, and removes the action.
The action menu option text is "Join group: insert_group_id_here".

Caveats:
* Respawn will possibly break this script.
* The action will be shown as long as you stay close to the unit, even if you already joined the unit. Using the action repeatedly to join the same group shouldn't have any ill effects though.
* Players in vehicles aren't checked for, leader needs to exit for his group to be joinable.

Parameters:
f/common/f_groupJoinAddOption.sqf has a single parameter: a boolean which decides whether joining groups on a side different to the player is allowed. This is set to false by default.

Files:
* init.sqf: executes f_groupJoinAddOption.sqf
* NEW: f/common/f_groupJoinAddOption.sqf: runs the main loop, monitoring for nearby joinable units, adding the join option when criteria is fulfilled
* NEW: f/common/f_groupJoinAction.sqf: executed by the action menu option to join the indicated group