Advertisement
Lurifaxen

Untitled

Mar 24th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 4.03 KB | None | 0 0
  1. private["_display","_spawnButton","_listBox","_listItemIndex","_numberOfSpawnPoints","_randNum","_randData","_randomSpawnIndex"];
  2. disableSerialization;
  3. diag_log "Selecting spawn location...";
  4. ExileClientSpawnLocationSelectionDone = false;
  5. ExileClientSelectedSpawnLocationMarkerName = "";
  6. createDialog "RscExileSelectSpawnLocationDialog";
  7. waitUntil
  8. {
  9.     _display = findDisplay 24002;
  10.     !isNull _display
  11. };
  12. _display displayAddEventHandler ["KeyDown", "_this call ExileClient_gui_loadingScreen_event_onKeyDown"];
  13. _listBox = _display displayCtrl 24002;
  14. lbClear _listBox;
  15. {
  16.     if (getMarkerType _x == "ExileSpawnZone") then
  17.     {
  18.         _listItemIndex = _listBox lbAdd (markerText _x);
  19.         _listBox lbSetData [_listItemIndex, _x];
  20.     };
  21. } forEach allMapMarkers;
  22.  
  23. _numberOfSpawnPoints = {getMarkerType _x == "ExileSpawnZone"} count allMapMarkers;
  24. if(_numberOfSpawnPoints > 0)then
  25. {
  26.     _randNum = floor(random _numberOfSpawnPoints);
  27.     _randData = lbData [24002,_randNum];
  28.     _randomSpawnIndex = _listBox lbAdd "Random";
  29.     _listBox lbSetData [_randomSpawnIndex, _randData];
  30. };
  31.  
  32. if(isNil "XG_Fnc_TempFNC") then
  33. {
  34.     defaultLBsize = lbSize _listBox;
  35.     myUID = getPlayerUID player;
  36.     myFlags = [];
  37.     {
  38.         _flag = _x;
  39.         _buildRights = _flag getVariable ["ExileTerritoryBuildRights", []];
  40.         if(myUID in _buildRights)then
  41.         {
  42.             _name = _flag getVariable ["ExileTerritoryName", ""];
  43.             _lbid = _listBox lbAdd _name;
  44.             _listBox lbSetColor [_lbid, [0,0.68,1,1]];
  45.             _listBox lbSetData [_lbid,str(count myFlags)];
  46.             myFlags pushBack _flag;
  47.         };
  48.     } forEach (allMissionObjects "Exile_Construction_Flag_Static");
  49.  
  50.     fnc_LBSelChanged_24002 =
  51.     {
  52.         disableSerialization;
  53.         _ctrl = _this select 0;
  54.         _curSel = lbCurSel _ctrl;
  55.         if(_curSel < defaultLBsize)then
  56.         {
  57.             _this call ExileClient_gui_selectSpawnLocation_event_onListBoxSelectionChanged;
  58.         }
  59.         else
  60.         {
  61.             _data = _ctrl lbData _curSel;
  62.             _num = parseNumber _data;
  63.             _flag = myFlags select _num;
  64.            
  65.             markerName = format['FLAG_%1',myUID];
  66.             deleteMarker markerName;
  67.             createMarker [markerName,getPosATL _flag];
  68.             markerName setMarkerAlpha 0;
  69.             createMarkerLocal [markerName,getPosATL _flag];
  70.             ExileClientSelectedSpawnLocationMarkerName = markerName;
  71.            
  72.             localmarkerName = format['LOCALFLAG_%1',myUID];
  73.             deleteMarkerLocal localmarkerName;
  74.             _marker = createMarkerLocal [localmarkerName,getPosATL _flag];
  75.             _marker setMarkerShapeLocal "ICON";
  76.             _marker setMarkerTypeLocal "loc_Bunker";
  77.             _marker setMarkerColorLocal "ColorGreen";
  78.             _marker setMarkerTextLocal (_flag getVariable ["ExileTerritoryName", ""]);
  79.            
  80.             _mapControl = (findDisplay 24002) displayCtrl 24001;
  81.             _mapControl ctrlMapAnimAdd [1, 0.1, getMarkerPos ExileClientSelectedSpawnLocationMarkerName];
  82.             ctrlMapAnimCommit _mapControl;
  83.         };
  84.     };
  85.     _listBox ctrlRemoveAllEventHandlers "LBSelChanged";
  86.     _listBox ctrlAddEventHandler ["LBSelChanged", "_this call fnc_LBSelChanged_24002;"];
  87.  
  88.     fnc_ButtonClick_24003 =
  89.     {
  90.         XG_Fnc_TempFNC =
  91.         {
  92.             [XG_Fnc_ThreadID] call ExileClient_system_thread_removeTask;
  93.             XG_Fnc_TempFNC = nil;
  94.         };
  95.         XG_Fnc_ThreadID = [900, XG_Fnc_TempFNC, [], false] call ExileClient_system_thread_addTask;
  96.         [] call ExileClient_gui_selectSpawnLocation_event_onSpawnButtonClick;
  97.         if(!isNil 'markerName')then
  98.         {
  99.             [] spawn
  100.             {
  101.                 waitUntil {!isNil 'ExileClientLoadedIn'};
  102.                 uiSleep 3;
  103.                 deleteMarker markerName;
  104.                 deleteMarkerLocal localmarkerName;
  105.                 ["SuccessTitleAndText", ["Anonymous - Base Spawn:", "You will be able to respawn at your base again in 15 minutes!"]] call
  106.                 ExileClient_gui_toaster_addTemplateToast;
  107.             };
  108.         };
  109.     };
  110.     _spawnButton = _display displayCtrl 24003;
  111.     _spawnButton ctrlRemoveAllEventHandlers "ButtonClick";
  112.     _spawnButton ctrlSetEventHandler["ButtonClick","call fnc_ButtonClick_24003"];
  113.     _spawnButton ctrlSetText "Let's go!";
  114.     _spawnButton ctrlEnable true;
  115.     _spawnButton ctrlCommit 0;
  116. }
  117. else
  118. {
  119.     ["ErrorTitleAndText", ["Anonymous - Base Spawn:", "There is a 15 minute cool down to base spawning!"]] call ExileClient_gui_toaster_addTemplateToast;
  120. };
  121. true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement