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 author
Documentation:
Author: code34
[email protected]
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
[email protected]
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];