Advertisement
Brenner650

ExAdClient\xm8\apps\DeployVehicle\config.sqf

Nov 25th, 2018
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.83 KB | None | 0 0
  1. ExAd_DV_DESPAWN_IDLE_TIME = 600;
  2.  
  3. ExAd_XM8_DV_fnc_itemsInCargo = {
  4.     params ["_container","_itemArray","_item","_amount","_response"];
  5.  
  6.     _item = toLower (_itemArray select 0);
  7.     _amount = _itemArray select 1;
  8.  
  9.     _response = false;
  10.     {
  11.         if(_item == toLower _x)then{
  12.             _amount = _amount - 1;
  13.         };
  14.         if(_amount <= 0)exitWith{_response = true}
  15.     }forEach magazines player;
  16.  
  17.     _response  
  18. };
  19.  
  20. ExAd_XM8_DV_fnc_itemsMissing = {
  21.     params["_recipe","_recipeStr"];
  22.    
  23.     _recipeStr = "";
  24.     {
  25.         private["_amount","_configName","_displayName","_text"];
  26.         _amount = if(count _x > 1)then{_x select 1}else{1};
  27.         _text = [_x select 0] call ExAd_XM8_DV_fnc_getDisplayName;
  28.         _recipeStr = _recipeStr + format["%1x : %2<br />",(if(_amount < 0)then{((-1) * _amount)}else{_amount}), _text];
  29.     }forEach _recipe;
  30.    
  31.     _response = format["You need <br />%1",_recipeStr];
  32.  
  33.     _response
  34. };
  35.  
  36. ExAd_XM8_DV_fnc_getDisplayName = {
  37.     params["_class","_configName","_displayName"];
  38.     _configName = _class call ExileClient_util_gear_getConfigNameByClassName;
  39.     _displayName = getText(configFile >> _configName >> _class >> "displayName");
  40.     _text = if(count _displayName > 0)then{_displayName}else{_class};
  41.  
  42.     _text
  43. };
  44.  
  45. ExAd_XM8_DV_fnc_canPack = {
  46.     ( ExileClientInteractionObject getVariable["ExAd_DV_Packable", false] )
  47. };
  48.  
  49. ExAd_XM8_DV_fnc_pack = {
  50.     [ExileClientInteractionObject] spawn {
  51.         params["_obj"];
  52.    
  53.         disableUserInput true;
  54.         player playActionNow "Medic";
  55.  
  56.         uiSleep 3;
  57.         ["despawnDeployableVehicle", [netId _obj]] call ExAd_fnc_serverDispatch;
  58.         uiSleep 1;
  59.  
  60.         ["SuccessTitleAndText", ["Vehicle Packed"]] call ExileClient_gui_toaster_addTemplateToast;
  61.         disableUserInput false;
  62.     };
  63. };
  64.  
  65. ExAd_XM8_DV_fnc_spawnVehicle = {
  66.     params["_slideClass","_bambiState","_delopyRecipe","_vehicleClass"];
  67.  
  68.     try
  69.     {  
  70.         _bambiState = if(isNumber(missionConfigFile >> "CfgXM8" >> _slideClass >> "bambiState")) then
  71.         {
  72.             if(getNumber(missionConfigFile >> "CfgXM8" >> _slideClass >> "bambiState") > 0)then{true}else{false}
  73.         } else {true};
  74.  
  75.         if(_bambiState && !ExileClientPlayerIsBambi) then { throw "You can only spawn vehicles as a bambi!"};
  76.  
  77.         _delopyRecipe = getArray(missionConfigFile >> "CfgXM8" >> _slideClass >> "recipe");
  78.         if(count _delopyRecipe > 0) then
  79.         {
  80.             {
  81.                 if(count _x > 1) then
  82.                 {
  83.                     _amount = if(_x select 1 == -1)then{1}else{_x select 1};
  84.                     if!([player, [_x select 0, _amount]] call ExAd_XM8_DV_fnc_itemsInCargo) then
  85.                     {
  86.                         throw ([_delopyRecipe] call ExAd_XM8_DV_fnc_itemsMissing);
  87.                     };
  88.                 } else {
  89.                     if!([player, _x select 0] call ExileClient_util_playerEquipment_contains) then
  90.                     {
  91.                         throw ([_delopyRecipe] call ExAd_XM8_DV_fnc_itemsMissing);
  92.                     }
  93.                 }
  94.             }forEach _delopyRecipe;
  95.  
  96.             {
  97.                 _count = if(count _x > 1)then{(_x select 1)}else{1};
  98.                 for "_i" from 1 to _count do {
  99.                     [player, _x select 0] call ExileClient_util_playerCargo_remove
  100.                 }
  101.             }forEach _delopyRecipe;
  102.         };
  103.  
  104.         _vehicleClass = getText(missionConfigFile >> "CfgXM8" >> _slideClass >> "vehicleClass");
  105.         if!(isClass(configFile >> "CfgVehicles" >> _vehicleClass ))then { throw "The vehicle class doesn't exist"};
  106.  
  107.         [_slideClass] spawn {
  108.             params["_slideClass"];
  109.             disableUserInput true;
  110.             player playActionNow "Medic";
  111.  
  112.             uiSleep 3;
  113.             ["spawnDeployableVehicle", [netId player, _slideClass]] call ExAd_fnc_serverDispatch;
  114.             uiSleep 1;
  115.             ["SuccessTitleAndText", ["Vehicle deployed"]] call ExileClient_gui_toaster_addTemplateToast;
  116.             ExileClientXM8CurrentSlide = "extraApps";
  117.             disableUserInput false;
  118.         }; 
  119.  
  120.         ["extraApps", 1] call ExileClient_gui_xm8_slide;
  121.         closeDialog 0;
  122.  
  123.  
  124.     }
  125.     catch{
  126.         [_exception] spawn {
  127.             UISleep 0.5;
  128.             ["ErrorTitleAndText", ["ExAd - Deploy Vehicle", _this select 0]] call ExileClient_gui_toaster_addTemplateToast;
  129.             ["extraApps", 1] call ExileClient_gui_xm8_slide;
  130.         };
  131.     };
  132. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement