Saving and retrieving custom variables

  1. 6 years ago

    Hi there!

    I'm using the example for a custom variable but for some reason I can't get it to return anything other than "any" when I'm loading it back.

    To save, I'm using:

    missionNamespace setVariable ["chaosFull", 1, true]; 
    ["chaosFullData", chaosFull] call ALiVE_fnc_setData;

    And to return the persistent variable, I'm using:

    chaosFull = ["chaosFullData"] call ALiVE_fnc_getData;

    However, after doing this, chaos is always null (even if it has been set as 0 before). What's weird is that in the aliveserver RPT I have these lines on saving:

    [2016-08-27 00:22:05] [debug]             - [{"commanderTargetKilled":1,"chaosFullData":1,"date":[2016,7,24,17,3],"Group":"RAJA"}]

    And these lines on loading:

    [2016-08-27 00:22:31] [debug]     Return value [['{"_id":"RAJA_ES8a","_rev":"1-3071ad7be157b43f2d0037c9d027d845","commanderTargetKilled":1,"chaosFullData":1,"date":[2016,7,24,17,3],"Group":"RAJA"}

    So it's saving and loading, I just can't get it to translate into my mission. Any ideas anybody?

  2. Edited 6 years ago by SpyderBlack723

    Assuming your real usage is portrayed 1:1 by your example,
    chaosFull needs to be a variable when you use fnc_setData


    chaosFull = 1;
    missionNamespace setVariable ["chaosFull", chaosFull, true];
    ["chaosFullData", chaosFull] call ALiVE_fnc_setData;
  3. Thanks Spyder! I'll give that a shot. I suspect I'd done that somewhere along the lines when testing but worth double checking.

  4. Edited 6 years ago by incontinenetia

    No luck it seems, still returns "any" even though the rpts show the variable has persisted. That's the weird thing - the variables are logged correctly in the rpt and they do show up when restarting the mission, so the data is persisting. The problem is that it's impossible to access that data via ALiVE_fnc_getData without something getting nulled along the way.

    Anybody had any luck with custom persistent variables?

  5. Edited 6 years ago by marceldev89

    Does [sys_data_mission_data, "chaosFull"] call ALIVE_fnc_hashGet; output anything different?

    EDIT: Or "chaosFullData" as key.. :)

  6. Edited 6 years ago by incontinenetia

    It doesn't seem to unfortunately. Just tried it on a fresh mission and confirmed the RPTs show the data persisting so that's a bit confusing.

    Edit: thanks for the suggestion though!

  7. Also, yup, used chaosFullData!

  8. So, anybody out there managed to use ALiVE_fnc_getData successfully? I've got a hacky workaround but it would be good to make sure this isn't a bug.

  9. Edited 6 years ago by SpyderBlack723

    Make sure you are executing this server side

    To ensure it's not a bug
    Inside init.sqf

    if (isServer) then {
        // get data
        if (isnil "_data") then {
            // set default
        hint str _data;
        // set data

    Then restart and see if it hints properly after restarting

  10. Finally got round to trying to get custom data to work and no luck, even if run on the server. I'll get a bug report going but just curious, has anyone else managed to get this working?

  11. 5 years ago

    No. Did you?

  12. This was a while back and I'm no longer able to play Arma (selling my PC) but I did actually manage to get it to work reliably. I think the trick was making sure it was only executed server side and not globally, then globalising the variable from a script running only on the server (as the ALiVE guys suggested). Feel free to have a dig around my group persistence script to see how I did it if you need clues. Specifically, I remote exec this script just on the server and it saves, loads and globalises a variable. Good luck!

  13. Thank you @incontinenetia I'm already doing all of that... will have to go back to empty missions. and see the basics of this stuff.


or Sign Up to reply!