Jump to content
Robert Tyburne

Trying to save variables within GRAD Persistence

Recommended Posts

Trying to use GRAD to save a variable, which is to be referenced after the mission is restarted to be used as part of an if-then statement to simply delete the zone since it's already been cleared by players.

 

The effect I'm going for is simple, which is a progression of clearing sectors by deleting marker areas (EOS zones) and planting a flag marker saying it's secure once the players destroy an object (like a transmitter). That so far has been simple enough:

 

Quote

safyrah_north_switch = createMarker ["safyrah_north_safe", getMarkerPos "safyrah_north_sector"];
safyrah_north_switch setMarkerType "hd_flag";
safyrah_north_switch setMarkerColor "ColorIndependent";
safyrah_north_switch setMarkerText "Al Safyrah North Sector: SECURE";
 

sleep 0.5;


missionNamespace setvariable ["safyrahnorth", 1, true];

if (missionNamespace getvariable "safyrahnorth" == 1) then {deleteMarker "safyrah_north_sector"};

["Al Safyrah North Sector: SECURE"] remoteexec ["hint", 0];


I'm attempting to set a public variable in the missionNameSpace, as that's what I think GRAD wants in order to save it properly.

 

GRAD Config:

Quote

class CfgGradPersistence {
         missionTag = "breath";
         loadOnMissionStart = 1;
         missionWaitCondition = "true";
         playerWaitCondition = "true";

 

         saveUnits = 0;
         saveVehicles = 3;
         saveContainers = 3;
         saveStatics = 0;
         saveMarkers = 3;
         saveTasks = 0;
         saveTriggers = 0;

   

         savePlayerInventory = 1;
         savePlayerDamage = 0;
         savePlayerPosition = 1;
         savePlayerMoney = 1;

         saveTeamAccounts = 0;
    
         class customVariables {
              class safyrah_north_var {
                 varName = "safyrahnorth";
                 varNamespace = "mission";
                 public = 1;
           };

    };   
};


For reference, the config is saving vehicles, containers, and markers created during the mission. Player position and inventory is also saved, in addition to credit count as I'm also using GRAD money menu.

I use a remoteexeccall to get the save function to go, which hasn't failed yet with all the other data.
 

Once the mission restarts, the following code is run from a separate .sqf called from the initServer.sqf

Quote

if (missionNamespace getvariable "safyrahnorth" == 1) exitWith {deleteMarker "safyrah_north_sector"};

 

I've also tried combinations of "safyrahnorth" == 1 and safyrahnorth == 1, but the error is that the variable is undefined. If I run the same scripts in the same session, it all executes fine. It's as if the variable "safyrahnorth" is getting destroyed as soon as the server shuts down, which makes me think I'm not executing the GRAD variable save correctly.


I'm unclear on where I'm going wrong, and some extra eyeballs would be greatly appreciated. Or suggestions on approaching this differently.

  • Like 1

Share this post


Link to post
Share on other sites

Hello, I'm somewhat having the same problem as you, and I was wondering if you ever figured out a fix?
Thanks! 

  • Like 1

Share this post


Link to post
Share on other sites

I also wanted to save multiple variables but failed on previous versions of GRAD.

 

Perhaps the new versions have fixed the issues I was having before.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×