Advertisement
skotracker

ExileServer_object_tree_network_chopTreeRequest

Apr 19th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 12.12 KB | None | 0 0
  1. /**
  2.  * ExileServer_object_tree_network_chopTreeRequest
  3.  *
  4.  * Exile Mod
  5.  * www.exilemod.com
  6.  * ? 2015 Exile Mod Team
  7.  *
  8.  * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
  9.  * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
  10.  */
  11.  
  12. private["_sessionId","_parameters","_treeNetId","_tree","_isTree","_player","_treeHeight","_newDamage","_treePosition","_spawnRadius","_weaponHolders","_weaponHolder","_weaponHolderPosition"];
  13. _sessionId = _this select 0;
  14. _parameters = _this select 1;
  15. _treeNetId = _parameters select 0;
  16.    
  17. ///////////////////////////////////
  18. //////Chop Trees Into Vehicles/////
  19. ///////////////////////////////////
  20. _woodText = "Wood dropped in your Area!";
  21. _woodVehicleText = "Wood was put inside your Vehicle!";
  22. _woodVehicleFullText = "Wood dropped in your Area! Vehicle is Full!";
  23. ///////////////////////////////////
  24.  
  25. try
  26. {
  27.     _tree = objectFromNetId _treeNetId;
  28.     if (isNull _tree) then
  29.     {
  30.         throw format ["Cannot chop unknown tree! %1", _treeNetId];
  31.     };
  32.     if !(alive _tree) then
  33.     {
  34.         throw "Cannot chop already chopped tree!";
  35.     };
  36.     _isTree = [_tree, "WoodSource"] call ExileClient_util_model_isInteraction;
  37.     if !(_isTree) then
  38.     {
  39.         throw "Can only chop down trees!";
  40.     };
  41.     _player = _sessionId call ExileServer_system_session_getPlayerObject;
  42.     if (isNull _player) then
  43.     {
  44.         throw "Unknown players cannot chop trees!";
  45.     };
  46.     if !(alive _player) then
  47.     {
  48.         throw "The dead cannot chop down trees!";
  49.     };
  50.     if ((_player distance _tree) > 30) then
  51.     {
  52.         throw "No long distance tree chopping! Nope!";
  53.     };
  54.     _treeHeight = _tree call ExileClient_util_model_getHeight;
  55.     _treeHeight = _treeHeight max 1;
  56.     _newDamage = ((damage _tree) + (1 / (floor _treeHeight) )) min 1;
  57.     _tree setDamage _newDamage;
  58.     if (_newDamage isEqualTo 1) then
  59.     {
  60.         _tree setDamage 999;
  61.     };
  62.    
  63. ///////////////////////////////////
  64. //////Chop Trees Into Vehicles/////
  65. ///////////////////////////////////
  66.             _nearestTruck = (getPosATL _tree) nearEntities[[
  67.            
  68.                         "Exile_Car_BRDM2_HQ",
  69.  
  70.                         "Exile_Car_BTR40_MG_Green","Exile_Car_BTR40_MG_Camo","Exile_Car_BTR40_Green","Exile_Car_BTR40_Camo",
  71.  
  72.                         "Exile_Car_Golf_Red","Exile_Car_Golf_Black",
  73.  
  74.                         "Exile_Car_Hatchback_Beige","Exile_Car_Hatchback_Green","Exile_Car_Hatchback_Blue","Exile_Car_Hatchback_BlueCustom",
  75.                         "Exile_Car_Hatchback_BeigeCustom","Exile_Car_Hatchback_Yellow","Exile_Car_Hatchback_Grey","Exile_Car_Hatchback_Black",
  76.                         "Exile_Car_Hatchback_Dark","Exile_Car_Hatchback_Rusty1","Exile_Car_Hatchback_Rusty2","Exile_Car_Hatchback_Rusty3",
  77.  
  78.                         "Exile_Car_Hatchback_Sport_Red","Exile_Car_Hatchback_Sport_Blue","Exile_Car_Hatchback_Sport_Orange","Exile_Car_Hatchback_Sport_White",
  79.                         "Exile_Car_Hatchback_Sport_Beige","Exile_Car_Hatchback_Sport_Green","Exile_Car_Hatchback_Sport_Admin",
  80.  
  81.                         "Exile_Car_HEMMT","HMMWV_M134","Exile_Car_HMMWV_M134_Green","Exile_Car_HMMWV_M134_Desert","HMMWV_M2","Exile_Car_HMMWV_M2_Green",
  82.                         "Exile_Car_HMMWV_M2_Desert","HMMWV_MEV","Exile_Car_HMMWV_MEV_Green","Exile_Car_HMMWV_MEV_Desert","HMMWV_UNA",
  83.                         "Exile_Car_HMMWV_UNA_Green","Exile_Car_HMMWV_UNA_Desert",
  84.  
  85.                         "Exile_Car_Hunter",
  86.                         "Exile_Car_Ifrit",
  87.  
  88.                         "Exile_Car_Ikarus_Blue","Exile_Car_Ikarus_Red","Exile_Car_Ikarus_Party",
  89.  
  90.                         "Exile_Car_Lada_Green","Exile_Car_Lada_Taxi","Exile_Car_Lada_Red","Exile_Car_Lada_White","Exile_Car_Lada_Hipster",
  91.  
  92.                         "Exile_Car_LandRover_Red","Exile_Car_LandRover_Urban","Exile_Car_LandRover_Green","Exile_Car_LandRover_Sand","Exile_Car_LandRover_Desert",
  93.                         "Exile_Car_LandRover_Ambulance_Green","Exile_Car_LandRover_Ambulance_Desert","Exile_Car_LandRover_Ambulance_Sand",
  94.  
  95.                         "Exile_Car_Octavius_White","Exile_Car_Octavius_Black",
  96.  
  97.                         "Exile_Car_Offroad_Red","Exile_Car_Offroad_Beige","Exile_Car_Offroad_White","Exile_Car_Offroad_Blue","Exile_Car_Offroad_DarkRed",
  98.                         "Exile_Car_Offroad_BlueCustom","Exile_Car_Offroad_Guerilla01","Exile_Car_Offroad_Guerilla02","Exile_Car_Offroad_Guerilla03",
  99.                         "Exile_Car_Offroad_Guerilla04","Exile_Car_Offroad_Guerilla05","Exile_Car_Offroad_Guerilla06","Exile_Car_Offroad_Guerilla07",
  100.                         "Exile_Car_Offroad_Guerilla08","Exile_Car_Offroad_Guerilla09","Exile_Car_Offroad_Guerilla10","Exile_Car_Offroad_Guerilla11",
  101.                         "Exile_Car_Offroad_Guerilla12","Exile_Car_Offroad_Rusty1","Exile_Car_Offroad_Rusty2","Exile_Car_Offroad_Rusty3",
  102.  
  103.                         "Exile_Car_Offroad_Armed_Guerilla01","Exile_Car_Offroad_Armed_Guerilla02","Exile_Car_Offroad_Armed_Guerilla03","Exile_Car_Offroad_Armed_Guerilla04",
  104.                         "Exile_Car_Offroad_Armed_Guerilla05","Exile_Car_Offroad_Armed_Guerilla06","Exile_Car_Offroad_Armed_Guerilla07","Exile_Car_Offroad_Armed_Guerilla08",
  105.                         "Exile_Car_Offroad_Armed_Guerilla09","Exile_Car_Offroad_Armed_Guerilla10","Exile_Car_Offroad_Armed_Guerilla11","Exile_Car_Offroad_Armed_Guerilla12",
  106.  
  107.                         "Exile_Car_Offroad_Repair_Civillian","Exile_Car_Offroad_Repair_Red","Exile_Car_Offroad_Repair_Beige","Exile_Car_Offroad_Repair_White",
  108.                         "Exile_Car_Offroad_Repair_Blue","Exile_Car_Offroad_Repair_DarkRed","Exile_Car_Offroad_Repair_BlueCustom","Exile_Car_Offroad_Repair_Guerilla01",
  109.                         "Exile_Car_Offroad_Repair_Guerilla02","Exile_Car_Offroad_Repair_Guerilla03","Exile_Car_Offroad_Repair_Guerilla04","Exile_Car_Offroad_Repair_Guerilla05",
  110.                         "Exile_Car_Offroad_Repair_Guerilla06","Exile_Car_Offroad_Repair_Guerilla07","Exile_Car_Offroad_Repair_Guerilla08","Exile_Car_Offroad_Repair_Guerilla09",
  111.                         "Exile_Car_Offroad_Repair_Guerilla10","Exile_Car_Offroad_Repair_Guerilla11","Exile_Car_Offroad_Repair_Guerilla12",
  112.  
  113.                         "Exile_Car_OldTractor_Red",
  114.                         "Exile_Car_Strider",
  115.  
  116.                         "Exile_Car_SUV_Red","Exile_Car_SUV_Black","Exile_Car_SUV_Grey","Exile_Car_SUV_Orange","Exile_Car_SUV_Rusty1","Exile_Car_SUV_Rusty2",
  117.                         "Exile_Car_SUV_Rusty3","SUV_Base",
  118.  
  119.                         "Exile_Car_SUVXL_Black","Exile_Car_SUV_Armed_Black",
  120.  
  121.                         "Exile_Car_Tempest",
  122.  
  123.                         "Exile_Car_TowTractor_White",
  124.  
  125.                         "Exile_Car_Tractor_Red",
  126.                         "Exile_Car_UAZ_Green","Exile_Car_UAZ_Open_Green",
  127.  
  128.                         "Exile_Car_Ural_Covered_Blue","Exile_Car_Ural_Covered_Yellow","Exile_Car_Ural_Covered_Worker","Exile_Car_Ural_Covered_Military","Exile_Car_Ural_Open_Blue",
  129.                         "Exile_Car_Ural_Open_Yellow","Exile_Car_Ural_Open_Worker","Exile_Car_Ural_Open_Military",
  130.  
  131.                         "Exile_Car_V3S_Covered","Exile_Car_V3S_Open",
  132.  
  133.                         "Exile_Car_Van_Black","Exile_Car_Van_White","Exile_Car_Van_Red","Exile_Car_Van_Guerilla01","Exile_Car_Van_Guerilla02",
  134.                         "Exile_Car_Van_Guerilla03","Exile_Car_Van_Guerilla04","Exile_Car_Van_Guerilla05","Exile_Car_Van_Guerilla06","Exile_Car_Van_Guerilla07",
  135.                         "Exile_Car_Van_Guerilla08",
  136.  
  137.                         "Exile_Car_Van_Box_Black","Exile_Car_Van_Box_White","Exile_Car_Van_Box_Red","Exile_Car_Van_Box_Guerilla01","Exile_Car_Van_Box_Guerilla02",
  138.                         "Exile_Car_Van_Box_Guerilla03","Exile_Car_Van_Box_Guerilla04","Exile_Car_Van_Box_Guerilla05","Exile_Car_Van_Box_Guerilla06","Exile_Car_Van_Box_Guerilla07",
  139.                         "Exile_Car_Van_Box_Guerilla08",
  140.  
  141.                         "Exile_Car_Van_Fuel_Black","Exile_Car_Van_Fuel_White","Exile_Car_Van_Fuel_Red","Exile_Car_Van_Fuel_Guerilla01","Exile_Car_Van_Fuel_Guerilla02","Exile_Car_Van_Fuel_Guerilla03",
  142.  
  143.                         "Exile_Car_Volha_Blue","Exile_Car_Volha_White","Exile_Car_Volha_Black",
  144.  
  145.                         "Exile_Car_Zamak",
  146.  
  147.                         "Exile_Bike_QuadBike_Black","Exile_Bike_QuadBike_Blue","Exile_Bike_QuadBike_Red","Exile_Bike_QuadBike_White","Exile_Bike_QuadBike_Nato","Exile_Bike_QuadBike_Csat","Exile_Bike_QuadBike_Fia",
  148.                         "Exile_Bike_QuadBike_Guerilla01","Exile_Bike_QuadBike_Guerilla02",
  149.  
  150.                         "Exile_Chopper_Hellcat_Green","Exile_Chopper_Hellcat_FIA",
  151.  
  152.                         "Exile_Chopper_Huey_Green","Exile_Chopper_Huey_Desert","Exile_Chopper_Huey_Armed_Green","Exile_Chopper_Huey_Armed_Desert",
  153.  
  154.                         "Exile_Chopper_Hummingbird_Green","Exile_Chopper_Hummingbird_Civillian_Blue","Exile_Chopper_Hummingbird_Civillian_Red","Exile_Chopper_Hummingbird_Civillian_ION",
  155.                         "Exile_Chopper_Hummingbird_Civillian_BlueLine","Exile_Chopper_Hummingbird_Civillian_Digital","Exile_Chopper_Hummingbird_Civillian_Elliptical",
  156.                         "Exile_Chopper_Hummingbird_Civillian_Furious","Exile_Chopper_Hummingbird_Civillian_GrayWatcher","Exile_Chopper_Hummingbird_Civillian_Jeans",
  157.                         "Exile_Chopper_Hummingbird_Civillian_Light","Exile_Chopper_Hummingbird_Civillian_Shadow","Exile_Chopper_Hummingbird_Civillian_Sheriff",
  158.                         "Exile_Chopper_Hummingbird_Civillian_Speedy","Exile_Chopper_Hummingbird_Civillian_Sunset","Exile_Chopper_Hummingbird_Civillian_Vrana",
  159.                         "Exile_Chopper_Hummingbird_Civillian_Wasp","Exile_Chopper_Hummingbird_Civillian_Wave",
  160.  
  161.                         "Exile_Chopper_Huron_Black","Exile_Chopper_Huron_Green",
  162.  
  163.                         "Exile_Chopper_Mohawk_FIA",
  164.  
  165.                         "Exile_Chopper_Orca_CSAT","Exile_Chopper_Orca_Black","Exile_Chopper_Orca_BlackCustom",
  166.  
  167.                         "Exile_Chopper_Taru_CSAT","Exile_Chopper_Taru_Black","Exile_Chopper_Taru_Covered_CSAT","Exile_Chopper_Taru_Covered_Black","Exile_Chopper_Taru_Transport_CSAT","Exile_Chopper_Taru_Transport_Black",
  168.                        
  169.                         "Exile_Plane_Ceasar","Exile_Plane_BlackfishInfantry","Exile_Plane_BlackfishVehicle",
  170.                         "Exile_Car_ProwlerLight","Exile_Car_ProwlerUnarmed",
  171.                         "Exile_Car_QilinUnarmed",
  172.                         "Exile_Car_MB4WD",
  173.                         "Exile_Car_MB4WDOpen",
  174.                        
  175.                         "I_C_Offroad_02_unarmed_F", "C_Offroad_02_unarmed_F",
  176.                         "B_T_LSV_01_armed_F", "B_T_LSV_01_unarmed_F", "O_T_LSV_02_armed_F","O_T_LSV_02_unarmed_F","B_T_UAV_03_F","C_Plane_Civil_01_F","O_T_UAV_04_CAS_F","B_T_VTOL_01_armed_F",
  177.                         "B_T_VTOL_01_infantry_F","B_T_VTOL_01_vehicle_F","O_T_VTOL_02_infantry_F","O_T_VTOL_02_vehicle_F","I_C_Boat_Transport_02_F","C_Scoooter_Transport_01_F"
  178.                        
  179.                         ], 50];
  180.                        
  181.             _weaponHolder = objNull;
  182.             if ((count _nearestTruck > 0)) then
  183.             {
  184.                 _truck = _nearestTruck select 0;
  185.                 if (_truck canAdd "Exile_Item_WoodLog") then
  186.                     {
  187.                     _truck addMagazineCargoGlobal ["Exile_Item_WoodLog", 1];
  188.                         [_sessionID, "toastRequest", ["SuccessTitleOnly", [_woodVehicleText]]] call ExileServer_system_network_send_to;
  189.                     }
  190.                     else
  191.                     {
  192.                         _treePosition = getPosATL _tree;
  193.                         _treePosition set[2, 0];
  194.                         _spawnRadius = 3;
  195.                         _weaponHolders = nearestObjects[_treePosition, ["GroundWeaponHolder"], _spawnRadius];
  196.                         _weaponHolder = objNull;
  197.                         if (_weaponHolders isEqualTo []) then
  198.                         {
  199.                             _weaponHolderPosition = [_treePosition, _spawnRadius] call ExileClient_util_math_getRandomPositionInCircle;
  200.                             _weaponHolderPosition set [2, 0];
  201.                             _weaponHolder = createVehicle ["GroundWeaponHolder", _weaponHolderPosition, [], 0, "CAN_COLLIDE"];
  202.                             _weaponHolder setPosATL _weaponHolderPosition;
  203.                         }
  204.                         else
  205.                         {
  206.                             _weaponHolder = _weaponHolders select 0;
  207.                         };
  208.                         _weaponHolder addMagazineCargoGlobal ["Exile_Item_WoodLog", 1];
  209.                         [_sessionID, "toastRequest", ["SuccessTitleOnly", [_woodVehicleFullText]]] call ExileServer_system_network_send_to;
  210.                     };
  211.             }
  212.             else
  213.             {
  214.            
  215.  
  216.     _treePosition = getPosATL _tree;
  217.     _treePosition set[2, 0];
  218.     _spawnRadius = 3;
  219.     _weaponHolders = nearestObjects[_treePosition, ["GroundWeaponHolder"], _spawnRadius];
  220.     _weaponHolder = objNull;
  221.     if (_weaponHolders isEqualTo []) then
  222.     {
  223.         _weaponHolderPosition = getPosATL _player;
  224.         _weaponHolder = createVehicle ["GroundWeaponHolder", _weaponHolderPosition, [], 0, "CAN_COLLIDE"];
  225.         _weaponHolder setPosATL _weaponHolderPosition;
  226.     }
  227.     else
  228.     {
  229.         _weaponHolder = _weaponHolders select 0;
  230.     };
  231.     _weaponHolder addMagazineCargoGlobal ["Exile_Item_WoodLog", 1];
  232.    
  233.  
  234.             [_sessionID, "toastRequest", ["SuccessTitleOnly", [_woodText]]] call ExileServer_system_network_send_to;
  235.             };         
  236.  
  237. }
  238. catch
  239. {
  240.     _exception call ExileServer_util_log;
  241. };
  242. true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement