I suggest not following Fluff's code. It wont work and that'll only save $var, and not $var[ID HERE]
If you were however, to use that method:
function GameConnection::saveVars(%client)
{
export("$var" @ %client.bl_id @ "*", "config/Vars/" @ %client.bl_id @ ".cs");
}
to load:
package autoLoad
{
function gameConnection::AutoAdminCheck(%client) //This is called once a client joins the server
{
if(isFile("config/Vars/" @ %client.bl_id @ ".cs"))
exec("config/Vars/" @ %client.bl_id @ ".cs");
else
%client.configureDefaultVars();
return Parent::AutoAdminCheck(%client);
}
};
activatePackage(autoLoad);
and to remove data of a user who has left the server:
package autoSave
{
function GameConnection::onClientLeaveGame(%client)
{
%client.saveVars();
deleteVariables("$var" @ %client.bl_id @ "*");
return Parent::onClientLeaveGame(%client);
}
};
activatePackage(autosave);
Explanations for each function:
Saving:Let's say the client's ID was 5344.
It would export anything as $var[5344,*], meaning, if you were to have something like $var[5344,faction] and $var[5344,points] it would save both to the file, instead of just one variable.
Auto load:Package the autoadmin check function, which is called whenever any player joins.
If the player has a file, load it, otherwise, give him default values (you would have to make this function yourself as GameConnection::configureDefaultValues(%client) )
And then for the autoadmin system to work properly, return whatever the default function is supposed to.
Auto save:Package the function for when clients leave the server.
Save the player's data using the previous function made, saveVars.
Delete the no longer needed variables.
Then continue the onLeave function.
Like in a bottom print.
Depends what you want to display.