Elioriel

fn_keyMenu.sqf

Jan 13th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.37 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3.     File: fn_keyMenu.sqf
  4.     Author: Bryan "Tonic" Boardwine
  5.  
  6.     Description:
  7.     Initializes the key menu
  8.     Will be revised.
  9. */
  10. private["_display","_vehicles","_plist","_near_units","_pic","_name","_text","_color","_index","_type","_p_units"];
  11. disableSerialization;
  12.  
  13. waitUntil {!isNull (findDisplay 2700)};
  14. _display = findDisplay 2700;
  15. _vehicles = _display displayCtrl 2701;
  16. lbClear _vehicles;
  17. _plist = _display displayCtrl 2702;
  18. lbClear _plist;
  19. _near_units = [];
  20. _p_units = playableUnits;
  21.  
  22. //{ if(player distance _x < 20) then {_near_units pushBack _x};} foreach playableUnits;
  23. {  _near_units pushBack (name _x); } foreach _p_units;
  24.  
  25. for "_i" from 0 to (count life_vehicles)-1 do {
  26.     _veh = life_vehicles select _i;
  27.     if(!isNull _veh && alive _veh) then {
  28.         _color = SEL(SEL(M_CONFIG(getArray,CONFIG_LIFE_VEHICLES,(typeOf _veh),"textures"),(_veh GVAR "Life_VEH_color")),0);
  29.         if(isNil "_color") then {_color = ""};
  30.         _text = format["(%1)",_color];
  31.         if(_text == "()") then {
  32.             _text = "";
  33.         };
  34.  
  35.         _name = getText(configFile >> "CfgVehicles" >> (typeOf _veh) >> "displayName");
  36.         _pic = getText(configFile >> "CfgVehicles" >> (typeOf _veh) >> "picture");
  37.         _vehicles lbAdd format["%1 %3 - [Distance: %2m]",_name,round(player distance _veh),_text];
  38.         if(_pic != "pictureStaticObject") then {
  39.             _vehicles lbSetPicture [(lbSize _vehicles)-1,_pic];
  40.         };
  41.         _vehicles lbSetData [(lbSize _vehicles)-1,str(_i)];
  42.     };
  43. };
  44.  
  45. /*
  46. {
  47.     if(!isNull _x && alive _x && player distance _x < 20 && _x != player) then {
  48.         _plist lbAdd format["%1 - %2",_x getVariable["realname",name _x], side _x];
  49.         _plist lbSetData [(lbSize _plist)-1,str(_x)];
  50.     };
  51. } foreach _near_units;
  52. */
  53.  
  54. _plist lbAdd format["%1","Cible"];
  55. _plist lbSetData [(lbSize _plist)-1,"targetkeygive"];
  56.  
  57. _near_units = _near_units call BIS_fnc_sortAlphabetically;
  58. {
  59.     _name = _x;
  60.     {
  61.         if ((!isNull _x) && {name _x == _name} && {alive _x} && {_x != player}) then
  62.         {
  63.             switch (side _x) do
  64.             {
  65.                 case west: {_type = "Cop";};
  66.                 case civilian: {_type = "Civ";};
  67.                 case independent: {_type = "Med";};
  68.                 case east {_type     = "adac";};
  69.             };
  70.             _plist lbAdd format["%1 (%2)",_x getVariable["realname",name _x], _type];
  71.             _plist lbSetData [(lbSize _plist)-1,str(_x)];
  72.         };
  73.     } foreach _p_units;
  74. } foreach _near_units;
  75.  
  76. if(((lbSize _vehicles)-1) == -1) then {
  77.     _vehicles lbAdd "You don't own any vehicles";
  78.     _vehicles lbSetData [(lbSize _vehicles)-1,str(ObjNull)];
  79. };
Add Comment
Please, Sign In to add comment