This is just a little sample using file objects. The save variables and the load variables inside of the save function and load function must be in the same order (when using this simple method). Notice how we use the packaged functions to save and load clients.
function saveClient(%this)
{
%f = new fileObject();
%f.openForWrite("filepath"@%this.bl_id@".txt");
%f.writeLine(%this.gold);//1
%f.writeLine(%this.level);//2
%f.close();
%f.delete();
}
function loadClient(%this)
{
%f = new fileObject();
%f.openForRead("filepath"@%this.bl_id@".txt");
%this.gold = %f.readLine();//1
%this.level = %f.readLine();//2
%f.close();
%f.delete();
}
//start of the it needs to be in a package package
function gameConnection::autoAdminCheck(%this)
{
parent::autoAdminCheck(%this);
//when someone joins, let's load them up!
loadClient(%this);
}
function gameConnection::onClientLeaveGame(%this)
{
//when someone leaves, let's save them before we call the parent!
saveClient(%this);
parent::gameConnection::onClientLeaveGame(%this);
}
//end of the needs to be in a package package