aeroson

Untitled

Oct 2nd, 2014
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.61 KB | None | 0 0
  1. /*
  2.  
  3. AUTHOR: aeroson
  4. NAME: group_manager.sqf
  5. VERSION: 1.6
  6.  
  7. DOWNLOAD & PARTICIPATE:
  8. https://github.com/aeroson/a3-misc
  9. http://forums.bistudio.com/showthread.php?163206-Group-Manager
  10.  
  11. DESCRIPTION:
  12. Hold T and use scrollwheel to see squad manager menu
  13. You can invite others, request to join, or join squad based on squad options
  14. You can also leave squad, kick members or take leadership if you have better score than current squad leader
  15. Potential targets is either cursorTrager and/or everyone within 5m range
  16.  
  17. USAGE:
  18. in (client's) init:
  19. 0 = [] execVM 'group_manager.sqf';
  20.  
  21. */
  22.  
  23. if(isDedicated) exitWith {}; // is server
  24. waitUntil{!isNull findDisplay 46};
  25.  
  26.  
  27. // SETTINGS
  28. #define KEY 0x14 // T // http://community.bistudio.com/wiki/DIK_KeyCodes
  29. #define TIMEOUT 120 // seconds
  30.  
  31. // SQUAD JOIN
  32. #define JOIN_FREE 0 // squad is open, anyone can join
  33. #define JOIN_INVITE_BY_SQUAD 1 // squad is invite only, everyone from squad can invite
  34. #define JOIN_INVITE_BY_LEADER 2 // squad is invite only, only leader can invite
  35. #define JOIN_DISABLED 3 // none can invite
  36. #define JOIN_DEFAULT JOIN_FREE
  37.  
  38. // SQUAD ACCEPT JOINT REQUEST PERMISSION (WHO CAN ACCEPT REQUEST) ONLY IF SQUAD JOIN IS 1, 2 OR 3
  39. #define ACCEPT_BY_SQUAD 0 // everyone from squad can accept join requests
  40. #define ACCEPT_BY_LEADER 1 // only leader can accept join requests
  41. #define ACCEPT_DISABLED 2 // disable join requests
  42. #define ACCEPT_DEFAULT ACCEPT_BY_LEADER
  43.  
  44.  
  45.  
  46.  
  47. #define PREFIX aero
  48. #define COMPONENT gm
  49. //#define DEBUG_MODE
  50.  
  51.  
  52. #define DOUBLES(A,B) ##A##_##B
  53. #define TRIPLES(A,B,C) ##A##_##B##_##C
  54. #define QUOTE(A) #A
  55. #define CONCAT(A,B) A####B
  56.  
  57. #define GVAR(A) TRIPLES(PREFIX,COMPONENT,A)
  58. #define QGVAR(A) QUOTE(GVAR(A))
  59.  
  60. #define INC(A) A=(A)+1
  61. #define DEC(A) A=(A)-1
  62. #define ADD(A,B) A=(A)+(B)
  63. #define SUB(A,B) A=(A)-(B)
  64. #define REM(A,B) A=A-[B]
  65. #define PUSH(A,B) A set [count (A),B]
  66. #define EL(A,B) ((A) select (B))
  67.  
  68. #define PUSH_START(A) A set[count (A),
  69. #define PUSH_END ];
  70. #define PARAM_START private ["_PARAM_INDEX"]; _PARAM_INDEX=0;
  71. #define PARAM_REQ(A) private #A; if(count _this<=_PARAM_INDEX)exitWith{ systemChat format["required param '%1' not supplied in file:'%2' at line:%3", #A ,__FILE__,__LINE__]; }; A=_this select _PARAM_INDEX; _PARAM_INDEX=_PARAM_INDEX+1;
  72. #define PARAM(A,B) private #A; A = (B); if(count _this>_PARAM_INDEX)then{ A=_this select _PARAM_INDEX; }; _PARAM_INDEX=_PARAM_INDEX+1;
  73.  
  74. #define THIS(A) EL(this,A)
  75. #define _THIS(A) EL(_this,A)
  76.  
  77. #ifdef DEBUG_MODE
  78. #define LOG(A) systemChat format[QUOTE(%1|%2(%3:%4)=%5),time,QUOTE(COMPONENT),__FILE__,__LINE__,A];
  79. #else
  80. #define LOG(A)
  81. #endif
  82.  
  83. #define TRACE_1(MSG,A) LOG(format['%1: A=%2',MSG,(A)])
  84. #define TRACE_2(MSG,A,B) LOG(format['%1: A=%2, B=%3',MSG,(A),(B)])
  85. #define TRACE_3(MSG,A,B,C) LOG(format['%1: A=%2, B=%3, C=%4',MSG,(A),(B),(C)])
  86. #define TRACE_4(MSG,A,B,C,D) LOG(format['%1: A=%2, B=%3, C=%4, D=%5',MSG,(A),(B),(C),(D)])
  87. #define TRACE_5(MSG,A,B,C,D,E) LOG(format['%1: A=%2, B=%3, C=%4, D=%5, E=%6',MSG,(A),(B),(C),(D),(E)])
  88. #define TRACE_6(MSG,A,B,C,D,E,F) LOG(format['%1: A=%2, B=%3, C=%4, D=%5, E=%6, F=%7',MSG,(A),(B),(C),(D),(E),(F)])
  89.  
  90.  
  91.  
  92.  
  93. GVAR(possibleTargets) = [];
  94. GVAR(actions_custom) = [];
  95. GVAR(actions_add) = {
  96. GVAR(actions_custom) set [count GVAR(actions_custom), _this];
  97. };
  98. GVAR(opened) = false;
  99.  
  100. GVAR(invites) = [];
  101. GVAR(requests) = [];
  102.  
  103. GVAR(msg) = {
  104. hint _this;
  105. systemChat _this;
  106. };
  107.  
  108.  
  109. GVAR(playersOnly) = {
  110. private ["_out"];
  111. _out = [];
  112. {
  113. if(isPlayer _x) then {
  114. PUSH_START(_out)
  115. _x
  116. PUSH_END
  117. };
  118. } forEach _THIS(0);
  119. _out;
  120. };
  121.  
  122. GVAR(actions_ids) = [];
  123. GVAR(actions_addId) = {
  124. GVAR(actions_ids) set [count GVAR(actions_ids), _this];
  125. };
  126. GVAR(actions_remove) = {
  127. {
  128. player removeAction _x;
  129. } forEach GVAR(actions_ids);
  130. GVAR(actions_ids) = [];
  131. };
  132. GVAR(actions_addBack) = {
  133. player addAction [
  134. "<t color='#cccccc'><img image='\A3\ui_f\data\gui\rsc\rscdisplayarcademap\icon_sidebar_show.paa' size='0.7' /> ... Back</t>",
  135. ([_this,0,{[] call GVAR(menu_main);}] call BIS_fnc_param),
  136. ([_this,1,[]] call BIS_fnc_param),
  137. 1000
  138. ] call GVAR(actions_addId);
  139. };
  140.  
  141.  
  142. // [unit1] // you have joined unit1's group
  143. GVAR(join) = {
  144. if(([group _THIS(0)] call GVAR(options_getJoin))!=JOIN_FREE) exitWith {
  145. format["%1's group (led by %2) is no longer free to join", name _THIS(0), name leader _THIS(0)] call GVAR(msg);
  146. };
  147. [
  148. format["%1 has joined your squad", name player],
  149. QGVAR(msg),
  150. [(units group _THIS(0))-[player]] call GVAR(playersOnly)
  151. ] spawn BIS_fnc_MP;
  152. format["You have joined %1's squad led by %2", name _THIS(0), name leader _THIS(0)] call GVAR(msg);
  153. [player] joinSilent group _THIS(0);
  154. waitUntil{group player==group _THIS(0)};
  155. [] call GVAR(menu_main);
  156. };
  157.  
  158. // you left your group
  159. GVAR(leaveGroup) = {
  160. LOG(QGVAR(leaveGroup))
  161. [
  162. format["%1 has left your squad", name player],
  163. QGVAR(msg),
  164. [(units group player)-[player]] call GVAR(playersOnly)
  165. ] spawn BIS_fnc_MP;
  166. "You have left squad" call GVAR(msg);
  167. [player] joinSilent createGroup (side player);
  168. [] call GVAR(menu_main);
  169. };
  170.  
  171.  
  172. // [unit1] // you have invited unit1 to join your group
  173. GVAR(invite) = {
  174. private ["_myJoin"];
  175. _myJoin = [group player] call GVAR(options_getJoin);
  176. if(!(
  177. (_myJoin==JOIN_FREE) ||
  178. (_myJoin==JOIN_INVITE_BY_SQUAD && player in units group player) ||
  179. (_myJoin==JOIN_INVITE_BY_LEADER && leader player == player)
  180. )) exitWith {
  181. "You no longer haver permission to invite" call GVAR(msg);
  182. };
  183. format["You have invited %1 into your squad", name _THIS(0)] call GVAR(msg);
  184. [
  185. format["%1 has invited %2 into your squad", name player, name _THIS(0)],
  186. QGVAR(msg),
  187. [(units group player)-[player]] call GVAR(playersOnly)
  188. ] spawn BIS_fnc_MP;
  189. [
  190. [
  191. player,
  192. group player
  193. ],
  194. QGVAR(invited),
  195. [[_THIS(0)]] call GVAR(playersOnly)
  196. ] spawn BIS_fnc_MP;
  197. [] call GVAR(menu_main);
  198. };
  199.  
  200. // [unit1, group1] // you got invited by unit1 to join a unit1's group1
  201. GVAR(invited) = {
  202. if(_THIS(0) in units _THIS(1)) then {
  203. format["%1 has invited you to join his/her squad (led by %2)", name _THIS(0), name leader _THIS(1)] call GVAR(msg);
  204. {
  205. if((_x select 1)==_THIS(0) && (_x select 2)==_THIS(1)) then {
  206. GVAR(invites) set[_forEachIndex, 0];
  207. };
  208. } forEach GVAR(invites);
  209.  
  210. PUSH_START(GVAR(invites))
  211. [time, _THIS(0), _THIS(1)]
  212. PUSH_END
  213. };
  214. [] call GVAR(menu_main);
  215. };
  216.  
  217. // [unit1, forEachIndex] // you have accepted invite by unit1 to unit1's group, forEachIndex in GVAR(invites)
  218. GVAR(invite_accepted) = {
  219. format["Invite by %1 (led by %2) accepted", name _THIS(0), name leader _THIS(0)] call GVAR(msg),
  220. [
  221. format["%1 has accepted your invite", name player],
  222. QGVAR(msg),
  223. [[_THIS(0)]] call GVAR(playersOnly)
  224. ] spawn BIS_fnc_MP;
  225. [
  226. format["%1 joined your group, invited by %2", name player, name _THIS(0)],
  227. QGVAR(msg),
  228. [(units group _THIS(0))-[_THIS(0)]] call GVAR(playersOnly)
  229. ] spawn BIS_fnc_MP;
  230. [player] joinSilent group _THIS(0);
  231. GVAR(invites) set[_THIS(1), 0];
  232. [] call GVAR(menu_main);
  233. };
  234.  
  235. // [unit1, forEachIndex] // you have declined invite by unit1 to unit1's group, forEachIndex in GVAR(invites)
  236. GVAR(invite_declined) = {
  237. format["Invite by %1 (led by %2) declined", name _THIS(0), name leader _THIS(0)] call GVAR(msg),
  238. [
  239. format["%1 has declined your invite", name player],
  240. QGVAR(msg),
  241. [[_THIS(0)]] call GVAR(playersOnly)
  242. ] spawn BIS_fnc_MP;
  243. GVAR(invites) set[_THIS(1), 0];
  244. [] call GVAR(menu_main);
  245. };
  246.  
  247.  
  248.  
  249.  
  250. // [unit1, unit2, accept:int] // unit1 is requesting to join unit2's group, accept is either ACCEPT_BY_SQUAD or ACCEPT_BY_LEADER
  251. GVAR(request) = {
  252. private ["_accept"];
  253. _accept = [group _THIS(1)] call GVAR(options_getAccept);
  254. if(!(
  255. (_accept==ACCEPT_BY_SQUAD && ({isPlayer _x} count units group unit2>0)) ||
  256. (_accept==ACCEPT_BY_LEADER && isPlayer leader group unit2)
  257. )) exitWith {
  258. format["You are no longer able to request join to %1's group (led by %2)", name _THIS(1), name leader _THIS(1)] call GVAR(msg);
  259. };
  260. format["You have requested to join %1's squad (led by %2)", name _THIS(1), name leader _THIS(1)] call GVAR(msg);
  261. [
  262. [
  263. _THIS(0),
  264. group _THIS(1)
  265. ],
  266. QGVAR(requested),
  267. [
  268. if(_accept==ACCEPT_BY_SQUAD) then { units group _THIS(1) } else { [leader _THIS(1)] }
  269. ] call GVAR(playersOnly)
  270. ] spawn BIS_fnc_MP;
  271. [] call GVAR(menu_main);
  272. };
  273.  
  274. // [unit1, group1] // unit1 requested to join yours group1
  275. GVAR(requested) = {
  276. if(player in units _THIS(1)) then {
  277. format["%1 has requested to join your squad", name _THIS(0), name leader _THIS(1)] call GVAR(msg);
  278. {
  279. if((_x select 1)==_THIS(0) && (_x select 2)==_THIS(1)) then {
  280. GVAR(requests) set[_forEachIndex, 0];
  281. };
  282. } forEach GVAR(requests);
  283. PUSH_START(GVAR(requests))
  284. [time, _THIS(0), _THIS(1)]
  285. PUSH_END
  286. };
  287. [] call GVAR(menu_main);
  288. };
  289.  
  290. // [unit1, forEachIndex] // you have accepted request from unit1 to join your group, forEachIndex in GVAR(requests)
  291. GVAR(request_accepted) = {
  292. format["Join request by %1 accepted", name _THIS(0)] call GVAR(msg),
  293. [
  294. format["%1 (led by %2) has accepted your join request", name player, name leader player],
  295. QGVAR(msg),
  296. [[_THIS(0)]] call GVAR(playersOnly)
  297. ] spawn BIS_fnc_MP;
  298. [
  299. format["%1 has joined your squad (accepted by %2)", name _THIS(0), name player],
  300. QGVAR(msg),
  301. [(units group player)-[player]] call GVAR(playersOnly)
  302. ] spawn BIS_fnc_MP;
  303. [_THIS(0)] joinSilent group player;
  304. GVAR(requests) set[_THIS(1), 0];
  305. [] call GVAR(menu_main);
  306. };
  307.  
  308. // [unit1, forEachIndex] // you have declined request from unit1 to join your group, forEachIndex in GVAR(requests)
  309. GVAR(request_declined) = {
  310. format["Join request by %1 declined", name _THIS(0)] call GVAR(msg),
  311. [
  312. format["%1 (led by %2) has declined your join request", name player, name leader player],
  313. QGVAR(msg),
  314. [[_THIS(0)]] call GVAR(playersOnly)
  315. ] spawn BIS_fnc_MP;
  316. GVAR(requests) set[_THIS(1), 0];
  317. [] call GVAR(menu_main);
  318. };
  319.  
  320.  
  321.  
  322. // you are taking leadership of your squad
  323. GVAR(takeLeaderShip) = {
  324. LOG(QGVAR(takeLeaderShip))
  325. if(!([player] call GVAR(canTakeLeadership))) exitWith {
  326. "You can't take leadership anymore" call GVAR(msg);
  327. [] call GVAR(menu_main);
  328. };
  329. "You took leadership" call GVAR(msg);
  330. [
  331. format["%1 has taken leadership", name player],
  332. QGVAR(msg),
  333. [(units group player)-[player, leader player]] call GVAR(playersOnly)
  334. ] spawn BIS_fnc_MP;
  335. _oldLeader = leader player;
  336. [
  337. [player],
  338. QGVAR(takeLeaderShip_remote),
  339. leader player
  340. ] spawn BIS_fnc_MP;
  341. waitUntil{_oldLeader!=leader player};
  342. [] call GVAR(menu_main);
  343. };
  344.  
  345. // [unit1] // unit1 takes leadership of his+yours group
  346. GVAR(takeLeaderShip_remote) = {
  347. if(group _THIS(0) == group player) then {
  348. if(isPlayer leader player) then {
  349. format["%1 took leadership from you", name _THIS(0)] call GVAR(msg);
  350. };
  351. (group player) selectLeader _THIS(0);
  352. [] call GVAR(menu_main);
  353. };
  354. };
  355.  
  356.  
  357. // [unit1] // returns true if unit1 can take leadership of his group, false if can't
  358. GVAR(canTakeLeadership) = {
  359. private["_out"];
  360. _out = true;
  361. if(count units group _THIS(0) == 1) then {
  362. _out = false;
  363. };
  364. if(leader _THIS(0) == _THIS(0)) then {
  365. _out = false;
  366. };
  367. if(isNil{aero_playtime_get}) then {
  368. if(rating leader _THIS(0) + 10 > rating _THIS(0)) then {
  369. _out = false;
  370. };
  371. } else {
  372. if(leader _THIS(0) call aero_playtime_get > ARG0 call aero_playtime_get) then {
  373. _out = false;
  374. };
  375. };
  376. _out;
  377. };
  378.  
  379.  
  380.  
  381. // show menu to give leadership
  382. GVAR(menu_giveLeaderShip) = {
  383. LOG(QGVAR(menu_giveLeaderShip))
  384. if(leader player!=player) exitWith {
  385. "You are not leader anymore" call GVAR(msg);
  386. [] call GVAR(menu_main);
  387. };
  388. [] call GVAR(actions_remove);
  389. {
  390. PUSH_START(GVAR(actions_ids))
  391. player addAction [
  392. format["<t color='#0099ee'><img image='\A3\ui_f\data\gui\Rsc\RscDisplayConfigViewer\bookmark_gs.paa' size='0.7' /> Give leadership to %1</t>", name _x],
  393. { _THIS(3) call GVAR(giveLeaderShip); },
  394. [_x],
  395. 5000-_forEachIndex
  396. ]
  397. PUSH_END
  398. } forEach ((units group player)-[player]);
  399. []call GVAR(actions_addBack);
  400. };
  401.  
  402.  
  403. // [unit1] // you gave group leadership to unit1
  404. GVAR(giveLeaderShip) = {
  405. format["You gave leadership to %1", name _THIS(0)] call GVAR(msg);
  406. [
  407. format["%1 was given leadership by %2", name _THIS(0), name player],
  408. QGVAR(msg),
  409. [(units group _THIS(0))-[_THIS(0), player]] call GVAR(playersOnly)
  410. ] spawn BIS_fnc_MP;
  411. [
  412. format["%1 gave you leadership", name player],
  413. QGVAR(msg),
  414. [[_THIS(0)]] call GVAR(playersOnly)
  415. ] spawn BIS_fnc_MP;
  416. (group _THIS(0)) selectLeader _THIS(0);
  417. [] call GVAR(menu_main);
  418. };
  419.  
  420.  
  421. // show menu for squad options
  422. GVAR(menu_squadOptions) = {
  423. LOG(QGVAR(menu_squadOptions))
  424. if(leader player!=player) exitWith {
  425. "You are not leader anymore" call GVAR(msg);
  426. [] call GVAR(menu_main);
  427. };
  428. [] call GVAR(actions_remove);
  429. private ["_join","_accept"];
  430. _join = [group player] call GVAR(options_getJoin);
  431. {
  432. PUSH_START(GVAR(actions_ids))
  433. player addAction [
  434. format["<t color='#0099ee'>%1 %2</t>", _x, if(_join==_forEachIndex) then {"(Current)"} else {""}],
  435. { _args=_THIS(3); (_args select 0) setVariable ["j", (_args select 1), true]; call GVAR(menu_squadOptions); },
  436. [group player, _forEachIndex],
  437. 6000-_forEachIndex
  438. ]
  439. PUSH_END
  440. } forEach ["Anyone can join","Squad members can invite","Squad leader can invite","Disable invite"];
  441. _accept = [group player] call GVAR(options_getAccept);
  442. {
  443. PUSH_START(GVAR(actions_ids))
  444. player addAction [
  445. format["<t color='#0077ee'>%1 %2</t>", _x, if(_accept==_forEachIndex) then {"(Current)"} else {""}],
  446. { _args=_THIS(3); (_args select 0) setVariable ["a", (_args select 1), true]; call GVAR(menu_squadOptions); },
  447. [group player, _forEachIndex],
  448. 5000-_forEachIndex
  449. ]
  450. PUSH_END
  451. } forEach ["Squad members can accept join request","Squad leader can accept join request","Disable join request"];
  452. [] call GVAR(actions_addBack);
  453. };
  454.  
  455. // show menu to kick squad member
  456. GVAR(menu_kickSquadMember) = {
  457. LOG(QGVAR(menu_kickSquadMember))
  458. if(leader player!=player) exitWith {
  459. "You are not leader anymore" call GVAR(msg);
  460. [] call GVAR(menu_main);
  461. };
  462. [] call GVAR(actions_remove);
  463. {
  464. PUSH_START(GVAR(actions_ids))
  465. player addAction [
  466. format["<t color='#ff8822'><img image='\A3\ui_f\data\gui\rsc\rscdisplayarcademap\top_close_gs.paa' size='0.7' /> Kick %1</t>", name _x],
  467. { _THIS(3) call GVAR(kickSquadMember); },
  468. [_x],
  469. 5000-_forEachIndex
  470. ]
  471. PUSH_END
  472. } forEach ((units group player)-[player]);
  473. []call GVAR(actions_addBack);
  474. };
  475.  
  476. // [unit1] // you are kicking unit1
  477. GVAR(kickSquadMember) = {
  478. LOG(QGVAR(kickSquadMember))
  479. format["You have kicked %1", name _THIS(0)] call GVAR(msg);
  480. [
  481. format["%1 was kicked by %2", name _THIS(0), name player],
  482. QGVAR(msg),
  483. [(units group _THIS(1))-[player, _THIS(0)]] call GVAR(playersOnly)
  484. ] spawn BIS_fnc_MP;
  485. [
  486. [player, _THIS(0)],
  487. QGVAR(kickSquadMember_remote),
  488. _THIS(0)
  489. ] spawn BIS_fnc_MP;
  490. waitUntil{!(_THIS(0) in units group player)};
  491. [] call GVAR(menu_main);
  492. };
  493.  
  494. // [unit1, unit2] // unit2 (local) have been kicked by unit1
  495. GVAR(kickSquadMember_remote) = {
  496. if(isPlayer _THIS(1)) then {
  497. format["You have been kicked by %1", name _THIS(0)] call GVAR(msg);
  498. };
  499. [_THIS(1)] joinSilent createGroup (side _THIS(1));
  500. [] call GVAR(menu_main);
  501. };
  502.  
  503.  
  504. // [group1] // returns JOIN_ option for group1
  505. GVAR(options_getJoin) = {
  506. private ["_join"];
  507. _join = _THIS(0) getVariable "j";
  508. if(isNil{_join}) then {
  509. _join = JOIN_DEFAULT;
  510. _THIS(0) setVariable ["j", _join, true];
  511. };
  512. _join;
  513. };
  514.  
  515. // [group1] // returns ACCEPT_ option for group1
  516. GVAR(options_getAccept) = {
  517. private ["_accept"];
  518. _accept = _THIS(0) getVariable "a";
  519. if(isNil{_accept}) then {
  520. _accept = ACCEPT_DEFAULT;
  521. _THIS(0) setVariable ["a", _accept, true];
  522. };
  523. _accept;
  524. };
  525.  
  526. // main menu D:
  527. GVAR(menu_main) = {
  528. [] call GVAR(actions_remove);
  529. if(!GVAR(opened)) exitWith {};
  530.  
  531. {
  532. PUSH(GVAR(actions_ids), player addAction _x);
  533. } forEach GVAR(actions_custom);
  534.  
  535. if(leader player == player) then {
  536. if(count units group player > 1)then {
  537. PUSH_START(GVAR(actions_ids))
  538. player addAction [
  539. "<t color='#0099ee'><img image='\A3\ui_f\data\gui\Rsc\RscDisplayConfigViewer\bookmark_gs.paa' size='0.7' /> Give Leadership to ...</t>",
  540. { _THIS(3) call GVAR(menu_giveLeaderShip); },
  541. [],
  542. 9010
  543. ]
  544. PUSH_END
  545. PUSH_START(GVAR(actions_ids))
  546. player addAction [
  547. "<t color='#ff8822'><img image='\A3\ui_f\data\gui\rsc\rscdisplayarcademap\top_close_gs.paa' size='0.7' /> Kick Squad Member ...</t>",
  548. { _THIS(3) call GVAR(menu_kickSquadMember); },
  549. [],
  550. 9030
  551. ]
  552. PUSH_END
  553. };
  554. PUSH_START(GVAR(actions_ids))
  555. player addAction [
  556. "<t color='#0088ee'><img image='\A3\ui_f\data\gui\rsc\rscdisplayarcademap\icon_config_ca.paa' size='0.7' /> Squad Options ...</t>",
  557. { _THIS(3) call GVAR(menu_squadOptions); },
  558. [],
  559. 9020
  560. ]
  561. PUSH_END
  562. } else {
  563. if([player] call GVAR(canTakeLeadership)) then {
  564. PUSH_START(GVAR(actions_ids))
  565. player addAction [
  566. "<t color='#0099ee'><img image='\A3\ui_f\data\gui\Rsc\RscDisplayConfigViewer\bookmark_gs.paa' size='0.7' /> Take Leadership</t>",
  567. { _THIS(3) call GVAR(takeLeaderShip) },
  568. [],
  569. 9000
  570. ]
  571. PUSH_END
  572. };
  573. };
  574.  
  575. if(count units group player > 1)then {
  576. PUSH_START(GVAR(actions_ids))
  577. player addAction [
  578. "<t color='#ff1111'><img image='\A3\ui_f\data\gui\rsc\rscdisplayarcademap\icon_sidebar_hide_up.paa' size='0.7' /> Leave squad</t>",
  579. { _THIS(3) call GVAR(leaveGroup) },
  580. [],
  581. 8000
  582. ]
  583. PUSH_END
  584. };
  585.  
  586.  
  587. // GVAR(invites) = [[time, unit1, group1], ] // you got invited by unit1 to join a unit1's group1
  588. GVAR(invites) = GVAR(invites) - [0];
  589. {
  590. _unit1 = _x select 1;
  591. if(_unit1 in units (_x select 2) && (_x select 0) + TIMEOUT > time) then {
  592. PUSH_START(GVAR(actions_ids))
  593. player addAction [
  594. format["<t color='#00cc00'><img image='\A3\ui_f\data\gui\rsc\rscdisplayarcademap\icon_continue_ca.paa' size='0.7' /> Accept invite by %1 (led by %2)</t>", name _unit1, name leader _unit1],
  595. { _THIS(3) call GVAR(invite_accepted) },
  596. [_unit1, _forEachIndex],
  597. 7500-_forEachIndex
  598. ]
  599. PUSH_END
  600. PUSH_START(GVAR(actions_ids))
  601. player addAction [
  602. format["<t color='#ff1111'><img image='\A3\ui_f\data\gui\rsc\rscdisplayarcademap\top_close_gs.paa' size='0.7' /> Decline invite by %1 (led by %2)</t>", name _unit1, name leader _unit1],
  603. { _THIS(3) call GVAR(invite_declined) },
  604. [_unit1, _forEachIndex],
  605. 7000-_forEachIndex
  606. ]
  607. PUSH_END
  608. } else {
  609. GVAR(invites) set [_forEachIndex, 0];
  610. };
  611. } forEach GVAR(invites);
  612. GVAR(invites) = GVAR(invites) - [0];
  613.  
  614.  
  615. // GVAR(requests) = [[time, unit1, group1], ] // unit1 requested to join yours group1
  616. GVAR(requests) = GVAR(requests) - [0];
  617. {
  618. _unit1 = _x select 1;
  619. if(player in units (_x select 2) && (_x select 0) + TIMEOUT > time) then {
  620. PUSH_START(GVAR(actions_ids))
  621. player addAction [
  622. format["<t color='#00cc00'><img image='\A3\ui_f\data\gui\rsc\rscdisplayarcademap\icon_continue_ca.paa' size='0.7' /> Accept join request by %1</t>", name _unit1],
  623. { _THIS(3) call GVAR(request_accepted) },
  624. [_unit1, _forEachIndex],
  625. 6500-_forEachIndex
  626. ]
  627. PUSH_END
  628. PUSH_START(GVAR(actions_ids))
  629. player addAction [
  630. format["<t color='#ff1111'><img image='\A3\ui_f\data\gui\rsc\rscdisplayarcademap\top_close_gs.paa' size='0.7' /> Decline join request by %1</t>", name _unit1],
  631. { _THIS(3) call GVAR(request_declined) },
  632. [_unit1, _forEachIndex],
  633. 6000-_forEachIndex
  634. ]
  635. PUSH_END
  636. } else {
  637. GVAR(requests) set [_forEachIndex, 0];
  638. };
  639. } forEach GVAR(requests);
  640. GVAR(requests) = GVAR(requests) - [0];
  641.  
  642.  
  643. private "_groupsDone";
  644. _groupsDone = [];
  645. _myJoin = [group player] call GVAR(options_getJoin);
  646. {
  647. if(
  648. side _x == side player && group _x != group player
  649. && alive _x && !(vehicle _x in allUnitsUav)
  650. ) then {
  651.  
  652. if(_myJoin!=JOIN_DISABLED && isPlayer _x) then {
  653. if(
  654. (_myJoin==JOIN_FREE) ||
  655. (_myJoin==JOIN_INVITE_BY_SQUAD && player in units group player) ||
  656. (_myJoin==JOIN_INVITE_BY_LEADER && leader player == player)
  657. ) then {
  658. PUSH_START(GVAR(actions_ids))
  659. player addAction [
  660. format["<t color='#ffcc66'><img image='\A3\ui_f\data\gui\rsc\rscdisplayarcademap\icon_toolbox_units_ca.paa' size='0.7' /> Invite %1 into your squad</t>", name _x],
  661. { _THIS(3) call GVAR(invite); },
  662. [_x],
  663. 5600-_forEachIndex
  664. ]
  665. PUSH_END
  666. };
  667. };
  668.  
  669. if(!(group _x in _groupsDone)) then {
  670. PUSH(_groupsDone, group _x);
  671. _join = [group _x] call GVAR(options_getJoin);
  672.  
  673. if(_join==JOIN_FREE) then {
  674. PUSH_START(GVAR(actions_ids))
  675. player addAction [
  676. format["<t color='#ffcc66'><img image='\A3\ui_f\data\gui\rsc\rscdisplayarcademap\icon_toolbox_units_ca.paa' size='0.7' /> Join %1's squad (led by %2)</t>", name _x, name leader _x],
  677. { _THIS(3) call GVAR(join); },
  678. [_x],
  679. 5300-_forEachIndex
  680. ]
  681. PUSH_END
  682. } else {
  683. _accept = [group _x] call GVAR(options_getAccept);
  684. if(
  685. (_accept==ACCEPT_BY_SQUAD && ({isPlayer _x} count units group _x>0)) ||
  686. (_accept==ACCEPT_BY_LEADER && isPlayer leader group _x)
  687. ) then {
  688. PUSH_START(GVAR(actions_ids))
  689. player addAction [
  690. format["<t color='#ffcc66'><img image='\A3\ui_f\data\gui\rsc\rscdisplayarcademap\icon_toolbox_units_ca.paa' size='0.7' /> Request to join %1's squad (led by %2)</t>", name _x, name leader _x],
  691. { _THIS(3) call GVAR(request); },
  692. [player, _x, _accept],
  693. 5000-_forEachIndex
  694. ]
  695. PUSH_END
  696. };
  697. };
  698. };
  699.  
  700. };
  701. } forEach GVAR(possibleTargets);
  702.  
  703. LOG(QUOTE(main_menu done))
  704. };
  705.  
  706.  
  707. (findDisplay 46) displayAddEventHandler ["keyDown", QUOTE(_this call GVAR(keyDown))];
  708. GVAR(keyDown) = {
  709. if(_THIS(1)==KEY) then {
  710. if(!GVAR(opened)) then {
  711. GVAR(opened) = true;
  712. GVAR(possibleTargets) = [];
  713. if(!isNull(group cursorTarget)) then {
  714. PUSH_START(GVAR(possibleTargets))
  715. cursorTarget
  716. PUSH_END
  717. };
  718. {
  719. if(!(_x in GVAR(possibleTargets))) then {
  720. PUSH_START(GVAR(possibleTargets))
  721. _x
  722. PUSH_END
  723. };
  724. } forEach nearestObjects [player, ["man"], 5];
  725. [] call GVAR(menu_main);
  726. };
  727. };
  728. false;
  729. };
  730.  
  731.  
  732. (findDisplay 46) displayAddEventHandler ["keyUp", QUOTE(_this call GVAR(keyUp))];
  733. GVAR(keyUp) = {
  734. if(_THIS(1)==KEY) then {
  735. if(GVAR(opened)) then {
  736. GVAR(opened) = false;
  737. [] call GVAR(actions_remove);
  738. };
  739. };
  740. false;
  741. };
  742.  
  743.  
  744. "squad manager is active, hold T and use mousewheel to bring it up" call GVAR(msg);
Advertisement
Add Comment
Please, Sign In to add comment