Persistent variable for custom data storage/recovery

  1. 8 years ago
    Edited 8 years ago by Iron

    Apologies if this is more appropriate for the Mission Makers tag, but as this is pretty niche and very much about persistence, this seemed the one to use.

    Does the persistent database provide me with any variable or function through which I can write my own data to be stored across sessions? I don't even have specifics at the moment of why I might use it, this is more of a "well, I know I'm going to want this sooner or later for something..."

    As an example off the top of my head, suppose I have some sort of vehicle requisition system. Think Bon's Infantry spawner but for vehicles, and I want to let players replace their (empty, not AI-crewed) vehicle losses over time. I would probably want to store some overall force pool value and modify that based on their time/frequency/type of vehicles requisitioned (spawned) that I would track. (I'm not actually proposing this, ALiVE logistics lets me do this already. It is merely a convenient and easy example.)

    Is there some particular variable or function into which I can dump this arbitrary array of whatever I might want to save, and on reloading a session with persistence enabled, ALiVE will spit that back into Arma that I might access and sort it out again for my various purposes?

    I know the Combat Support module does have the "CS_code" setvariable. I'm not sure if that gets saved and carried over across sessions or if it is just used when respawning a Combat Support asset but is set afresh from the module each time a mission is loaded on the server. (And would need to be reset each time a new Combat Support asset is manually registered by some other script.) It would be a hell of a hackjob, but if that does get updated and persists across sessions, I imagine I could try to inject my overfilled-array-of-whatever in there.

    If this isn't something I can do, does anyone know if there are any other options available to me? I know I could run iniDB on my server, but that seems like such a waste when ALiVE is already doing so much fantastic storage for me.

  2. I totally agree with you. This would be a nice feature. Maybe a dev will chime in and if this not a feature, then I will add it to the feature requests on their tracker.

  3. Friznit

    8 Jun 2015 Administrator

    Not possible to my knowledge at the moment. CS setvar isn't persisted. Unless/until we add a petsisted Custom var the only workaround would be to hack job an existing one such as force pool. Seems like a good idea and perhaps something we could add in the Db module. Need our DB junky to determine any issues and give you a real answer though!

  4. Tupolov

    8 Jun 2015 Administrator

    Add it as a feature request please and we'll put it in for 1.0

  5. http://dev.withsix.com/issues/76273

  6. Edited 8 years ago by Iron

    Well that's more than fair a response, Friznit and Tupolov!

    I've no doubt there are concerns about letting people write - or attempt to write - whatever they like into the database. I'm delighted that you'll think it over and look into it, that's all I can ask. I do appreciate it. :)

    (And Dixon, thanks for adding it so I can continue to be lazy and not do so, heh.)

  7. Tupolov

    10 Jun 2015 Administrator

    This was somewhat easier than i first thought! Will ship in next release.

  8. @Tupolov This was somewhat easier than i first thought! Will ship in next release.

    :D

    Thanks!

  9. Edited 8 years ago by PapaReap

    Does anyone know if there a check to see if the mission has any previous custom data set without getting errors?

    For the example script below everything is fine except for my conditon check on whether or not my custom data exists, my problem is -

    isTask1complete = ["task1complete"] call ALiVE_fnc_getData 

    If it doen't already exist it will error out. My isNil check is not correct in checking this data.
    Any ideas would be welcome. Thank you.

    Custom data, set in previous mission by trigger which saves and returns "true" as it should, is -

    if (isServer) then { ["task1complete", "true"] call ALiVE_fnc_setData; }; 

    Script below -

    if (isServer) then { 
        if (isNil "isTask1Complete") then { 
            isTask1complete = "false"; publicVariable "isTask1complete"; 
        }; 
    }; 
    
    waitUntil { sleep 10; !isNil "ALIVE_profileSystemInit" }; 
    
    if (isServer && isDedicated) then { 
        if !(isNil "(['task1complete'] call ALiVE_fnc_getData)") then { // this condition check does not work!!!
            isTask1complete = ["task1complete"] call ALiVE_fnc_getData; publicVariable "isTask1complete"; 
        }; 
    }; 
  10. Being able to do this would be awesome for the thing I am working on now, actually. I have a lot of custom player variables for a "fake" inventory type system (because I am lazy and don't want to spend all the time converting small objects to inventory items :P), as well as other things that would be nice to persist on the server if running on a dedicated machine, like the environmental traps.

  11. Edited 8 years ago by SpyderBlack723
    if (!isNil {["task1complete"] call ALiVE_fnc_getData}) then {CODE};

    It will execute the code if the data exists.

    Can do a full rewrite of your above example when I get home if you need it.

  12. @SpyderBlack723, this works brilliantly. I was close, but no cigar :(

    No re-write necessary unless you want to make it more clear for future people like myself looking for correct answers. I'm new to ALiVE myself, but finding it quite interesting.

    This opens up a whole new world on what our missions can include :)

    Thank you very much for your guidance.

 

or Sign Up to reply!