From 08d936196eec63902fbffb51f1af69b3c02ef078 Mon Sep 17 00:00:00 2001 From: DoubleRepo <34832750+DoubleRepo@users.noreply.github.com> Date: Mon, 25 Dec 2017 13:33:07 +0100 Subject: [PATCH] Add files via upload --- Exile.ini | 19 ++++ ...er_object_tree_network_chopTreeRequest.sqf | 87 ++++++++++++++++++ README.md | 24 ++++- Server Addon/TreeLogging.pbo | Bin 0 -> 3554 bytes .../TreeLogging/bootstrap/fn_postInit.sqf | 5 + .../TreeLogging/bootstrap/fn_preInit.sqf | 14 +++ Server Addon/TreeLogging/config.cpp | 25 +++++ .../functions/ExileServer_TreeLogging_log.sqf | 4 + .../ExileServer_object_tree_database_load.sqf | 20 ++++ ...ExileServer_world_loadAllDatabaseTrees.sqf | 35 +++++++ Sql Instructions.txt | 9 ++ Tree.sql | 40 ++++++++ 12 files changed, 281 insertions(+), 1 deletion(-) create mode 100644 Exile.ini create mode 100644 MpMission/overwrites/ExileServer_object_tree_network_chopTreeRequest.sqf create mode 100644 Server Addon/TreeLogging.pbo create mode 100644 Server Addon/TreeLogging/bootstrap/fn_postInit.sqf create mode 100644 Server Addon/TreeLogging/bootstrap/fn_preInit.sqf create mode 100644 Server Addon/TreeLogging/config.cpp create mode 100644 Server Addon/TreeLogging/functions/ExileServer_TreeLogging_log.sqf create mode 100644 Server Addon/TreeLogging/functions/ExileServer_object_tree_database_load.sqf create mode 100644 Server Addon/TreeLogging/functions/ExileServer_world_loadAllDatabaseTrees.sqf create mode 100644 Sql Instructions.txt create mode 100644 Tree.sql diff --git a/Exile.ini b/Exile.ini new file mode 100644 index 0000000..e749353 --- /dev/null +++ b/Exile.ini @@ -0,0 +1,19 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Tree dammnit +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +[loadTreeIdPage] +SQL1_1 = SELECT id FROM tree LIMIT ?,? +Number Of Inputs = 2 +SQL1_INPUTS = 1,2 +OUTPUT = 1 + +[loadTree] +SQL1_1 = SELECT position_x, position_y, position_z FROM tree WHERE id = ? +Number Of Inputs = 1 +SQL1_INPUTS = 1 +OUTPUT = 1,2,3 + +[insertTree] +SQL1_1 = INSERT INTO tree SET position_x = ?, position_y = ?, position_z = ? +Number of Inputs = 3 +SQL1_INPUTS = 1,2,3 \ No newline at end of file diff --git a/MpMission/overwrites/ExileServer_object_tree_network_chopTreeRequest.sqf b/MpMission/overwrites/ExileServer_object_tree_network_chopTreeRequest.sqf new file mode 100644 index 0000000..f633438 --- /dev/null +++ b/MpMission/overwrites/ExileServer_object_tree_network_chopTreeRequest.sqf @@ -0,0 +1,87 @@ +/** + * ExileServer_object_tree_network_chopTreeRequest + * + * Exile Mod + * www.exilemod.com + * © 2015 Exile Mod Team + * + * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. + * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/. + */ + +private["_sessionId", "_parameters", "_treeNetId", "_tree", "_isTree", "_player", "_treeHeight", "_newDamage", "_treePosition", "_spawnRadius", "_weaponHolders", "_weaponHolder", "_health", "_weaponHolderPosition"]; +_sessionId = _this select 0; +_parameters = _this select 1; +_treeNetId = _parameters select 0; +try +{ + _tree = objectFromNetId _treeNetId; + if (isNull _tree) then + { + throw format ["Cannot chop unknown tree! %1", _treeNetId]; + }; + if !(alive _tree) then + { + throw "Cannot chop already chopped tree!"; + }; + _isTree = [_tree, "WoodSource"] call ExileClient_util_model_isInteraction; + if !(_isTree) then + { + throw "Can only chop down trees, you twat!"; + }; + _player = _sessionId call ExileServer_system_session_getPlayerObject; + if (isNull _player) then + { + throw "Unknown players cannot chop trees!"; + }; + if !(alive _player) then + { + throw "The dead cannot chop down trees!"; + }; + if ((_player distance _tree) > 30) then + { + throw "No long distance tree chopping! Nope!"; + }; + _treeHeight = _tree call ExileClient_util_model_getHeight; + _treeHeight = _treeHeight max 1; + _newDamage = ((damage _tree) + (1 / (floor _treeHeight) )) min 1; + _tree setDamage _newDamage; + if (_newDamage isEqualTo 1) then + { + _tree setDamage 999; + }; + _treePosition = getPosATL _tree; + _treePosition set[2, 0]; + _spawnRadius = 3; + _weaponHolders = nearestObjects[_treePosition, ["GroundWeaponHolder"], _spawnRadius]; + _weaponHolder = objNull; + + + // Persistent Tree Logging Edits + _health = getDammage _tree; + _data = [_treePosition select 0, _treePosition select 1, _treePosition select 2]; + if (_health isEqualTo 1) then + { + _extDB2Message = ["insertTree", _data] call ExileServer_util_extDB2_createMessage; + _extDB2Message call ExileServer_system_database_query_fireAndForget; + }; + // Persistent Tree Logging Edits + + + if (_weaponHolders isEqualTo []) then + { + _weaponHolderPosition = getPosATL _player; + _weaponHolder = createVehicle ["GroundWeaponHolder", _weaponHolderPosition, [], 0, "CAN_COLLIDE"]; + _weaponHolder setPosATL _weaponHolderPosition; + } + else + { + _weaponHolder = _weaponHolders select 0; + }; + _weaponHolder addMagazineCargoGlobal ["Exile_Item_WoodLog", 1]; +} +catch +{ + _exception call ExileServer_util_log; +}; +true \ No newline at end of file diff --git a/README.md b/README.md index be4fef5..d159e6e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,24 @@ # PersistentTreeLogging -Persistent Tree logging on Exile. +Tree Logging Persistent for Exile. + +## Configuration + +Add inside your mission config.cpp at the cfgcustomcode ExileServer_object_tree_network_chopTreeRequest and use the file provided inside MpMission/overwrites. + +Drag the Server Addon to your ExileServer Addons folder and profit. + +Oyeeh, don't forget to read the Sql Instructions.txt + + +## Donations + +Fuck you and you're donations, send them to Exile. + +http://www.exilemod.com/donate/make-donation/ + +## Credits + +Original code base by CoftSock. + +## License +Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) diff --git a/Server Addon/TreeLogging.pbo b/Server Addon/TreeLogging.pbo new file mode 100644 index 0000000000000000000000000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xH ztW+BoWGYoe-rafCw798Z%GjKAf?k)?E6NETw}y)$JOn9bfh#B4cNLVw;+TKyHkcos zwzd?)&alS`p1Bil!|fL^kQ8u15+yS-exfcr+hMFtsRYSWq*#dhz_tlFV%Mk}>|0Gd z84X~-lABrfTM|oXAUCUC&DH{#P^M$0ZfJ5Q$+}Xz3x1u)P7sV7uxcrX|;b54i zpk6JUavJCm$)PZ=KtU-a;R(D7rpdk_%?)hc0&J+E5jE&m(EGUWyxSy3k{O;Y(sD-E z97k<^y)?b(1R>uTKRy8erI*ygX@y$WZt=hUH;#z=ehe>5xS3c*ku1_TzW$pWplbm$&m5?|yai4`L5# AJpcdz literal 0 HcmV?d00001 diff --git a/Server Addon/TreeLogging/bootstrap/fn_postInit.sqf b/Server Addon/TreeLogging/bootstrap/fn_postInit.sqf new file mode 100644 index 0000000..c13c403 --- /dev/null +++ b/Server Addon/TreeLogging/bootstrap/fn_postInit.sqf @@ -0,0 +1,5 @@ +"TreeLogging PostInit started..." call ExileServer_TreeLogging_log; + +[] call ExileServer_world_loadAllDatabaseTrees; + +"TreeLogging PostInit finished..." call ExileServer_TreeLogging_log; diff --git a/Server Addon/TreeLogging/bootstrap/fn_preInit.sqf b/Server Addon/TreeLogging/bootstrap/fn_preInit.sqf new file mode 100644 index 0000000..936ac68 --- /dev/null +++ b/Server Addon/TreeLogging/bootstrap/fn_preInit.sqf @@ -0,0 +1,14 @@ +private["_code"]; + +{ + _code = compileFinal (preprocessFileLineNumbers (_x select 1)); + missionNamespace setVariable [(_x select 0), _code]; +} +forEach +[ + ['ExileServer_world_loadAllDatabaseTrees', 'TreeLogging\functions\ExileServer_world_loadAllDatabaseTrees.sqf'], + ['ExileServer_object_tree_database_load', 'TreeLogging\functions\ExileServer_object_tree_database_load.sqf'], + ['ExileServer_TreeLogging_log', 'TreeLogging\functions\ExileServer_TreeLogging_log.sqf'] +]; + +"TreeLogging PreInit finished" call ExileServer_TreeLogging_log; diff --git a/Server Addon/TreeLogging/config.cpp b/Server Addon/TreeLogging/config.cpp new file mode 100644 index 0000000..ee9ae6a --- /dev/null +++ b/Server Addon/TreeLogging/config.cpp @@ -0,0 +1,25 @@ +class CfgPatches { + class TreeLogging { + requiredVersion = 0.1; + requiredAddons[] = { + "exile_server" + }; + units[] = {}; + weapons[] = {}; + }; +}; +class CfgFunctions { + class TreeLogging { + class main { + file="TreeLogging\bootstrap"; + class preInit + { + preInit = 1; + }; + class postInit + { + postInit = 1; + }; + }; + }; +}; diff --git a/Server Addon/TreeLogging/functions/ExileServer_TreeLogging_log.sqf b/Server Addon/TreeLogging/functions/ExileServer_TreeLogging_log.sqf new file mode 100644 index 0000000..8867137 --- /dev/null +++ b/Server Addon/TreeLogging/functions/ExileServer_TreeLogging_log.sqf @@ -0,0 +1,4 @@ +private["_msg"]; + +_msg = format["Exile TreeLogging log: %1",_this]; +diag_log _msg; \ No newline at end of file diff --git a/Server Addon/TreeLogging/functions/ExileServer_object_tree_database_load.sqf b/Server Addon/TreeLogging/functions/ExileServer_object_tree_database_load.sqf new file mode 100644 index 0000000..b63efe4 --- /dev/null +++ b/Server Addon/TreeLogging/functions/ExileServer_object_tree_database_load.sqf @@ -0,0 +1,20 @@ +/** + * ExileServer_object_tree_database_load + * + * Exile Mod + * www.exilemod.com + * © 2015 Exile Mod Team + * + * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. + * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/. + */ + +private["_treeID", "_data", "_position", "_Tree", "_SelectTree"]; +_treeID = _this; +_data = format ["loadTree:%1", _treeID] call ExileServer_system_database_query_selectSingle; +_position = [_data select 0, _data select 1, _data select 2]; +_Tree = nearestTerrainObjects [_position, ["Tree"], 5]; +_SelectTree = _Tree select 0; +diag_log format ["Hiding Tree @ %1", _SelectTree]; +_SelectTree hideObjectGlobal true; +true \ No newline at end of file diff --git a/Server Addon/TreeLogging/functions/ExileServer_world_loadAllDatabaseTrees.sqf b/Server Addon/TreeLogging/functions/ExileServer_world_loadAllDatabaseTrees.sqf new file mode 100644 index 0000000..7f0993e --- /dev/null +++ b/Server Addon/TreeLogging/functions/ExileServer_world_loadAllDatabaseTrees.sqf @@ -0,0 +1,35 @@ +/** + * ExileServer_world_loadAllDatabaseTrees + * + * Exile Mod + * www.exilemod.com + * © 2015 Exile Mod Team + * + * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. + * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/. + */ + +private["_continueLoading", "_page", "_pageSize", "_TreeIDs", "_numberOfTrees", "_i"]; +"Loading trees from database..." call ExileServer_TreeLogging_log; +_continueLoading = true; +_page = 0; +_pageSize = 100; +while {_continueLoading} do +{ + _TreeIDs = format ["loadTreeIdPage:%1:%2", _page * _pageSize, _pageSize] call ExileServer_system_database_query_selectFull; + _numberOfTrees = count _TreeIDs; + if (_numberOfTrees > 0) then + { + for "_i" from 0 to _numberOfTrees - 1 do + { + ((_TreeIDs select _i) select 0) call ExileServer_object_tree_database_load; + }; + }; + _page = _page + 1; + if (_numberOfTrees < 100) then + { + _continueLoading = false; + }; +}; +"Done loading trees!" call ExileServer_TreeLogging_log; +true \ No newline at end of file diff --git a/Sql Instructions.txt b/Sql Instructions.txt new file mode 100644 index 0000000..723d86e --- /dev/null +++ b/Sql Instructions.txt @@ -0,0 +1,9 @@ +SQL instructions: + +Import the Tree.sql and after that create a "scheduler" inside your MySQL database. + +Import this scheduler task: + +CREATE DEFINER=`root`@`localhost` EVENT `Re-grow tree's` ON SCHEDULE EVERY 1 HOUR STARTS '2017-12-11 11:11:11' ON COMPLETION PRESERVE ENABLE DO Delete FROM `tree` WHERE DATE(added) < DATE(NOW() - INTERVAL 10 DAY) + +And turn the scheduler ON! \ No newline at end of file diff --git a/Tree.sql b/Tree.sql new file mode 100644 index 0000000..285be91 --- /dev/null +++ b/Tree.sql @@ -0,0 +1,40 @@ +SET FOREIGN_KEY_CHECKS=0; +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + + +-- +-- Tabelstructuur `tree` +-- + +CREATE TABLE `tree` ( + `id` int(11) UNSIGNED NOT NULL, + `position_x` double DEFAULT NULL, + `position_y` double DEFAULT NULL, + `position_z` double DEFAULT NULL, + `added` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- +-- Indexen `tree` +-- +ALTER TABLE `tree` + ADD PRIMARY KEY (`id`); +-- +-- AUTO_INCREMENT `tree` +-- +ALTER TABLE `tree` + MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7; +SET FOREIGN_KEY_CHECKS=1; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; \ No newline at end of file