code34 248 Posted February 2, 2014 Persistent Data World Lastest version: 0.91 by Code34 Want to contribute by donation ? Github: https://github.com/code34/oo_pdw.Altis Reference: http://forums.bistudio.com/showthread.php?167980-Object-Oriented-SQF-Scripting-and-Compiling Download : https://github.com/code34/oo_pdw.Altis/releases Armaholic : http://www.armaholic.com/page.php?id=24548 Description OO PDW is a class (object oriented) that permits to save & restore world and players datas and make worlds persistent. This object uses Object Oriented SQF scripting of Naught and can use INIDBI2 addon or server/client profiles.Features: Save & restore all objects Save & restore players Save & restore infantry groups (AI) Save & restore inventory Filters options to include / exclude somes objects, etc Licence: Under Gpl, you can share, modify, distribute this script but don't remove the licence and the name of the original authorDocumentation: Author: code34 nicolas_boiteux@yahoo.fr Copyright (C) 2013-2018 Nicolas BOITEUX CLASS OO_PDW - Pesistent Data World This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------------------------------------------- Function: _pdw = ["new", "inidbi"] call OO_PDW; Create a new pdw object with a specific driver inidbi requires inidbi addons (only avalaible on windows) Parameters: string - can be "inidbi" or "profile" -------------------------------------------------------------------------------------------------------------- Function: ["setSaveName", "nameofsave"] call _pdw; Set the name of the save Parameters: string - name of the save Return : nothing -------------------------------------------------------------------------------------------------------------- Function: ["setDbName", "mydb"] call _pdw; Set the DB name for inidbi (Not avalaible for profile) Parameters: string - name of the inidbi db Return : nothing -------------------------------------------------------------------------------------------------------------- Function: _bool = ["savePlayer", _player] call _pdw; Save playable unit informations: position, damage, dir Parameters: _player - playable unit object Return : True if success -------------------------------------------------------------------------------------------------------------- Function: _bool = ["loadPlayer", _player] call _pdw; Load playable unit informations : position, damage, dir Parameters: _player - playable unit object Return : True if success -------------------------------------------------------------------------------------------------------------- Function: _bool = ["saveUnit", _unit] call _pdw; Save unit : type, position, damage, dir Parameters: _unit - unit object (MAN unit) Return : True if success -------------------------------------------------------------------------------------------------------------- Function: _unit = ["loadUnit", [_label, _group]] call _pdw; Load unit : type, position, damage, dir Parameters: _label - string label for the unit _group - group object where the unit have to be restore Return : unit otherwise false; -------------------------------------------------------------------------------------------------------------- Function: _bool = ["loadInventory", [_label, _unit]] call _pdw; Load a preset of equipment (all stuffs in backpacks, weapons, etc) Parameters: _label : string label for the preset _unit : unit object which will load the preset inventory Return : True if success -------------------------------------------------------------------------------------------------------------- Function: _bool = ["saveInventory", [_label, _unit]] call _pdw; Save in a preset all the equipment of the unit (all stuffs in backpacks, weapons, etc) Parameters: _label : string label for the preset _unit : unit object which will be used to save the preset inventory Return : True if success -------------------------------------------------------------------------------------------------------------- Function: ["clearInventory", _unit] call _pdw; Remove all the equipement Parameters: _unit : unit object where the inventory will be clear Return : Nothing -------------------------------------------------------------------------------------------------------------- Function: ["clearObject", _object] call _pdw; Remove all the cargo Parameters: _object : object where all cargo will be removed Return : Nothing -------------------------------------------------------------------------------------------------------------- Function: "savePlayers" call _pdw; Save all players informations and inventory presets Parameters: nothing Return : Nothing -------------------------------------------------------------------------------------------------------------- Function: "loadPlayers" call _pdw; Load all players informations and inventory presets Parameters: nothing Return : Nothing -------------------------------------------------------------------------------------------------------------- Function: _bool = "saveGroups" call _pdw; Save all AI groups informations and inventory presets Parameters: nothing Return : True if success -------------------------------------------------------------------------------------------------------------- Function: "loadGroups" call _pdw; Load all AI groups informations and inventory presets Parameters: nothing Return : Nothing -------------------------------------------------------------------------------------------------------------- Function: "saveObjects" call _pdw; Save all objects informations : type, position, damage according the filters If no filters, all objects are saved (except soldiers & logics) filter methods (describe above): setIncludingMarkers setExcludingMarkers setAroundPos setExcludingTypes setIncludingTypes setExcludingObjects setIncludingObjects Parameters: none Return : True if success -------------------------------------------------------------------------------------------------------------- Function: ["setIncludingMarkers", _array] call _pdw; Set array of markers containing objects to save Parameters: _array : array containing objects Return : none -------------------------------------------------------------------------------------------------------------- Function: ["setExcludingMarkers", _array] call _pdw; Set array of markers where objects don't have to be save Parameters: _array : array containing objects Return : none -------------------------------------------------------------------------------------------------------------- Function: ["setAroundPos", _array] call _pdw; Set array of positions of x distance perimeter, where objects have to be save Parameters: _array : array containing [[position, distance], [position, distance], ..] Return : none -------------------------------------------------------------------------------------------------------------- Function: ["setExcludingTypes", _array] call _pdw; Set array of of objects type, dont have to be save. Parameters: _array : array containing types of object ["B_Heli_Light_01_F"] Return : none -------------------------------------------------------------------------------------------------------------- Function: ["setIncludingTypes", _array] call _pdw; Set array of of objects type to whitelist Parameters: _array : array containing types of object ["B_Heli_Light_01_F"] Return : none -------------------------------------------------------------------------------------------------------------- Function: ["setExcludingObjects", _array] call _pdw; Set array of of objects, dont have to be save. Parameters: _array : array containing object Return : none -------------------------------------------------------------------------------------------------------------- Function: ["setIncludingObjects", _array] call _pdw; Set array of of objects that have to be save Parameters: _array : array containing object Return : none ------------------------------------------------------------------------------------------------------------ Function: _array = "loadObjects" call _pdw; Load and return all objects loaded Parameters: none Return : array of objects -------------------------------------------------------------------------------------------------------------- Function: _bool = ["saveObject", [_label, _object]] call _pdw; Save object, and all its cargo Parameters: _label : string label of the object to save _object : object Return : True if success -------------------------------------------------------------------------------------------------------------- Function: _object = ["loadObject", _label] call _pdw; Load object and return object loaded Parameters: _label : string label of the object to load Return : object -------------------------------------------------------------------------------------------------------------- Function: ["delete", _pdw] call OO_PDW; Destroy the pdw object Parameters: object - pdw object Return : nothing Readme: /* Author: code34 nicolas_boiteux@yahoo.fr Copyright (C) 2013-2018 Nicolas BOITEUX CLASS OO_PDW - Pesistent Data World This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ Create a main bus message between clients & server Usage: put the "oo_pdw.sqf" and the "oop.h" files in your mission directory put this code into your mission init.sqf call compile preprocessFileLineNumbers "oo_pdw.sqf"; See example mission in directory: init.sqf Licence: You can share, modify, distribute this script but don't remove the licence and the name of the original author logs: 0.91 - fix including / excluding objects (duplicate objects) 0.9 - update oop.h - add setIncludingTypes method from contributor: [LTC] Vegas =21st= - add debug entry points 0.8 - fix private keywords - fix array reference - fix clearcargo - add setSaveName method 0.76 - Add setIncludingMarkers method - Add setExcludingMarkers method - Add setAroundPos method - Add setExcludingTypes method - Add setExcludingObjects method - Add setIncludingObjects method - Delete saveObjectsAroundPos method - Delete saveObjectsInMarkers method - Delete saveObjectsOutOfMarkers method - Delete saveObjectsExcludingObjects method - Delete saveObjectsExcludingTypes - Control type methods parameters 0.74 - fix magazines count for infantry - turn off gps add - fix binocular not assigned - Add saveObjectsAroundPos method - Add saveObjectsInMarkers method - Add saveObjectsOutOfMarkers method - Add saveObjectsExcludingObjects method - Add saveObjectsExcludingTypes 0.72 - fix return values of methods - add savePlayers/loadPlayers methods - add saveGroups/loadGroups methods - fix initServer.sqf example for MP servers - update documentation 0.7 - add support inidbi2 DB - refactory setFileName to setDbName - only compatible with inidbi2 - fix saveObjects method 0.6 - add setFileName for inidbi DB - fix save file with inidbi - use UID instead of name of players 0.5 - add drivers support - add profilename support - add loadPlayer & savePlayer methods - fix loadInventory method 0.4 - re factory saveUnit, loadUnit, saveObject, loadObject - add saveObjects, loadObjects - add saveInventory, loadInventory, clearInventory - add more doc 0.3 - fix function name - fix reload weapon - fix example code 0.2 - Fix typo error, fix adduniform 0.1 - OO PDW - first release Examples call compile preprocessFileLineNumbers "oo_pdw.sqf"; sleep 2; private _pdw = ["new", "profile"] call OO_PDW; ["setSaveName", missionName] call _pdw; hint "save AI infantry groups"; "saveGroups" call _pdw; sleep 2; {deletevehicle _x;} foreach allunits; sleep 1; hint "load AI infantry groups"; "loadGroups" call _pdw; sleep 2; hint "Save all players"; "savePlayers" call _pdw; sleep 2; hint "Restore all Players"; "loadPlayers" call _pdw; sleep 2; //Filters example //_aroundpos = [[position player, 100], [position chopper, 10]]; //["setAroundPos", _aroundpos] call _pdw; //["setExcludingTypes", ["B_Heli_Light_01_F"]] call _pdw; //["setExcludingMarkers", ["test1", "test2"]] call _pdw; hint "Save all objects"; "saveObjects" call _pdw; sleep 2; hint "Delete all objects"; { if!(_x isKindOf "MAN") then { deletevehicle _x; }; }foreach (allMissionObjects "All"); sleep 2; _objects = "loadObjects" call _pdw; hint format ["Restore all objects %1", _objects]; 3 1 Share this post Link to post Share on other sites
.kju 3244 Posted February 2, 2014 Thanks for sharing - great stuff :bounce3: Share this post Link to post Share on other sites
mariodu62 5 Posted February 3, 2014 Very nice... Maybe would be nice to have functions like check if db exists. i think it would be very usefull for checking with onconnected player. Share this post Link to post Share on other sites
Guest Posted February 3, 2014 Release frontpaged on the Armaholic homepage. Object Oriented Persistent Data World (OO PDW) v0.1iniDBI ================================================ We have also "connected" these pages to your account on Armaholic. This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have. When you have any questions already feel free to PM or email me! Share this post Link to post Share on other sites
d3lta 10 Posted February 3, 2014 Is ALIVE compatible? Share this post Link to post Share on other sites
code34 248 Posted February 3, 2014 (edited) Very nice...Maybe would be nice to have functions like check if db exists. i think it would be very usefull for checking with onconnected player. I just add the comit :) ---------- Post added at 20:52 ---------- Previous post was at 20:51 ---------- Is ALIVE compatible? you can use it with Alive, but it doesn't require Alive. Edited February 3, 2014 by code34 Share this post Link to post Share on other sites
d3lta 10 Posted February 4, 2014 I just add the comit :)---------- Post added at 20:52 ---------- Previous post was at 20:51 ---------- you can use it with Alive, but it doesn't require Alive. Great!!! Thanks Share this post Link to post Share on other sites
d3lta 10 Posted February 5, 2014 Hi Code34, Is the code ( below ) the correct approach to use oopdw? _pdw = ["new"] call OO_PDW; waitUntil { ["SavePlayer", player] call _pdw; sleep 1; false } Is a bad code? alternatives? best regards Share this post Link to post Share on other sites
code34 248 Posted February 5, 2014 (edited) hi, you should not use a condition test on the "SavePlayer" method cause for the moment, there is not a clearly return for the whole method. So it s better to use directly: _pdw = ["new"] call OO_PDW; ["SavePlayer", player] call _pdw; memo: it s a on development version (on github) so things will change inside the code and db a lot in the next days. Edited February 5, 2014 by code34 Share this post Link to post Share on other sites
mikhail 10 Posted February 23, 2014 So I'm posting in this thread hoping someone can help me with a project I'm working on. I'm currently working on a custom wasteland server and what I'm trying to do is get vehicles and munitions boxes to save using inidbi. (just like they can now save base buildings) This way players can have their crates and vehicles after a server restart. Code34 you said in your other thread : you can save a lot of kinds of information but not directly object. You have to serialize them and restore them (ex: backup the class, and createvehicle to restore it).if you want more information on how to do this, you can look PDW: http://forums.bistudio.com/showthread.php?172499-OO-PDW-oriented-object-Persistent-Data-World I'm not a coder at all but I think I understand what you mean. Essentially the object has to be given an id(aka serialize) and then after the server is restarted the server would re-spawn them in. That would work perfectly. The only problem is....... I have no clue how to code that. Hasn't someone out there done something like this before? Share this post Link to post Share on other sites
code34 248 Posted March 2, 2014 hi :) if you are not a coder it s not the good place, cause PDW is a class for coder :) Share this post Link to post Share on other sites
soulis6 24 Posted May 7, 2014 Maybe i'm doing something wrong, but I can't seem to get this to work. I opened the example and took a look, and copied the Init sequence to my Init.sqf. Looking at the code in there, it saves the player's equipment, removes all equipment, and loads equipment, but when I attempt to save again in another function, like this: FNC_savePlayer = { _pdw = ["new"] call OO_PDW; ["SavePlayer", player] call _pdw; }; no errors are returned in the log, but it doesn't seem to save the player. When I call load again in the Init, it just reloads the same starting equipment. Has anyone had success with this? I've been having a huge hassle of a time getting basic saving/loading of equipment working, it seems like every example file I can find for IniDB or iniDBI just throws errors and doesn't work at all. Share this post Link to post Share on other sites
soulis6 24 Posted May 28, 2014 Bump, anyone still using this, or have any alternatives to saving loading equipment and the like? Share this post Link to post Share on other sites
code34 248 Posted May 28, 2014 Hi, do you check your "player" return value ? Share this post Link to post Share on other sites
mariodu62 5 Posted October 5, 2014 Hi, I would like to use this to save a client variable (earned money for example). But i don't see how to send a variable to the database (server of course). I did it with getvariable and setvariable (public) but i would like to send it directly. Share this post Link to post Share on other sites
code34 248 Posted November 5, 2014 hi Mario ! You have to share your variables before between client and server. Inidbi only write/read variables on media when you ask it on the local host wich executes the code. There is no transfering methode from inidbi. Share this post Link to post Share on other sites
dreadedentity 278 Posted November 5, 2014 Hi,I would like to use this to save a client variable (earned money for example). But i don't see how to send a variable to the database (server of course). I did it with getvariable and setvariable (public) but i would like to send it directly. publicVariableServer would be a much better option Share this post Link to post Share on other sites
code34 248 Posted November 8, 2014 Hi Guys, Just release the v0.2 :) - fix typo errors - fix adduniform Share this post Link to post Share on other sites
hannibal2210 1 Posted November 12, 2014 I have been having trouble getting the example mission to work (Tried the latest from github and the one on armaholic). I get the hints ingame that equipment is being removed and then loaded etc but nothing is being saved to an .ini file at all in the @inidbi/db folder. There are some script errors in the rpt, I hope I have not done anything wrong but would appreciate any help on this. Thanks http://pastebin.com/QbcQrKgM - RPT Share this post Link to post Share on other sites
code34 248 Posted November 12, 2014 (edited) Hi :) just upload a 0.3 version fix for pdw: - fix reload - fix function names - fix example codes Hannibal for your error, it s relative to inidbi, it's because you write an array with nil elements inside like [nil, "test", "other"]; Edited November 12, 2014 by code34 Share this post Link to post Share on other sites
Guest Posted November 12, 2014 New version frontpaged on the Armaholic homepage. Object Oriented Persistent Data World (OO PDW) v0.3iniDBI ================================================ We have also "connected" these pages to your account on Armaholic. This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have. When you have any questions already feel free to PM or email me! Share this post Link to post Share on other sites
MANTIA 55 Posted November 13, 2014 Would this save R3F Logistic building materials spawned in with the creation zone in game? I ask because ALiVE's persistence feature does not work with the creation zone items, only objects placed in the editor. Share this post Link to post Share on other sites
code34 248 Posted November 13, 2014 Hi Doro, i dont know how works the R3 logisitic. As it s early version, i don't think at this moment you can do what you want, can you give me more informations ? Share this post Link to post Share on other sites
code34 248 Posted November 14, 2014 Hi guys Just release the 0.4 version. This version permits to: - save&restore vehicles and objects - save&restore units - save&restore inventory logs: 0.4 - re factory saveUnit, loadUnit, saveObject, loadObject - add saveObjects, loadObjects - add saveInventory, loadInventory, clearInventory - add more doc As it's a early release i needed to re factory function names to make it more understable and efficient. Share this post Link to post Share on other sites