Saving Variables - gruppe-adler/grad-persistence GitHub Wiki
You can save any custom variable by adding it to the customVariables
class in CfgGradPersistence
. Note that the variable's classname does not matter. The varName
attribute is what defines the variables name.
Namespaces
The varNamespace
attribute defines where grad-persistence looks for your variable. For example if you have a script that does mcd_myVariable_test = 1337;
, this variable is saved in missionNamespace
and you need to use varNamespace = "mission";
.
If you have a script that saves a variable in a unit, for example _unit setVariable ["mcd_myVariable_test",1337]
, this variable is saved in the unit's namespace and you need to use varNamespace = "unit";
.
The following varNamespace
values can be used:
- mission
- unit
- group
- vehicle
- static
- gradFortificationsStatic
- container
- player
- trigger
Public
If the public
attribute is set to 1, this variable will be broadcast across the network. This basically does publicVariable
on mission load.
Limitations
Since grad-persistence only saves on server, you can only save variables that are known to the server. So if a client defines a variable locally, without making it public, you will not be able to save this variable.
For all namespaces other than mission
, variables will obviously only be saved, if the namespace object is being saved. That means you can't save a variable with e.g varNamespace = "vehicle";
if you turn off vehicle saving by setting saveVehicles = 0;
. It also means that if you are using the area
parameter with grad_persistence_fnc_saveMission, the vehicle has to be inside the area or else it won't be saved, and the variable won't be saved either.
Example
class CfgGradPersistence {
class customVariables {
class var1 {
varName = "mcd_myVariable_test";
varNamespace = "mission";
public = 0;
};
class var2 {
varName = "mcd_myPublicVariableOnAUnit_test";
varNamespace = "unit";
public = 1;
};
};
};