Author Topic: FileObjects - Saving and Loading Data  (Read 1510 times)

this really isn't that good.

and bragging that it has never had "corrupted data" is silly because even Sassy never corrupted anything.

it would be like an engineer bragging "btw my elevators have never fallen 20 stories."

I think someone said awhile ago all DRPG accounts reset because the data was corrupt.
Destiny's just clearing up that data corruption wasn't the reason why, if that's the case.

This is pretty much what I ended up doing:

Code: [Select]
function CreateDataSO()
{
if(isObject(DataSO))
DataSO.delete();

if(isFile("config/server/SaveData.cs"))
exec("config/server/SaveData.cs");

if(!isObject(DataSO))
new ScriptObject(DataSO){};

for(%a=0; %a<ClientGroup.getCount(); %a++)
LoadData(%cl);
}

function SaveData(%cl)
{
if(!isObject(DataSO))
CreateDataSO();
DataSO.SaveData[%cl.bl_id] = %cl.info TAB %cl.name;
DataSO.Save("config/server/SaveData.cs");
}

function LoadData(%cl)
{
if(!isObject(DataSO))
CreateDataSO();
%path = DataSO.SaveData[%cl.bl_id];

if(%path $= "")
DataSO.SaveData[%cl.bl_id] = 0 TAB %cl.name;
%cl.info = getWord(%path, 0);
//would of course be repeated for more information loading
}

function DeleteData(%cl)
{
if(!isObject(DataSO))
CreateDataSO();
DataSO.SaveData[%cl.bl_id] = "";
SaveData(%cl);
LoadData(%cl);
}

One thing is that with that kind of system you should never save e.g. object IDs directly. Saving something like "PlayerNoJet" or "BL_ID = 130" would be more reliable than "object 2344", "object 12387" as things will not be created in the same order for the next time you run the server and may not even be right. (that ID might be a brick, player or just not used if you run the server with fewer add-ons, or a datablock if you have more)

this really isn't that good.

and bragging that it has never had "corrupted data" is silly because even Sassy never corrupted anything.

it would be like an engineer bragging "btw my elevators have never fallen 20 stories."
I was simply mentioning it because of what Truce said and because of how often rpg servers get corrupted (see: wallets rob)

i always use scriptobjects and use fileIO to save it to certain files.

though that's just me