Author Topic: Aoki's CityRPG  (Read 1374 times)

Seems we need a new cityRPG code.
New loving saving/loading system sassy is loving stuff.


Seems we need a new cityRPG code.
The code on the server is pretty crappy, that's why it lags so loving much

Use Port's JSON.
No, seriously.

It lags because it takes too much memory, right? If so then I should be able to make it delete/save data on leave, and then re-load on enter.
Code: [Select]

function God::loadData(%db, %client)
{
%file = %db.directory@%client.bl_id@".cs";

if(isFile(%file))
{
exec(%file);
}
}

function God::saveData(%db, %client)
{
%file = new FileObject();
%file.openForWrite(%db.directory@%client.bl_id@".cs");

%Data = %db.getData(%client.bl_id);

if(findclientbyname(%client.name) == %client)
{
for(%a = 1; %a <= %db.valueCount; %a++)
{
%file.writeLine(%db.getName()@".getData("@%client.bl_id@").value"@%db.value[%a]@" = \""@%Data.value[%Data.parent.value[%a]]@"\";");
}
}

%file.close();
%file.delete();
}
function gameConnection::onClientEnterGame(%this)
{
parent::onClientEnterGame(%this);

if(!isObject(CityRPData.getData(%this.bl_id)))
{
CityRPData.addData(%this.bl_id);
}

if(isObject(CityRPMini))
{
CityRPMini.addMember(%this);
}
else
{
CityRP_BuildMinigame();
}

// I wouldn't do that if I were you...
centerPrint(%this, "<bitmap:Add-Ons/GameMode_CityRP/Iban>", 5);
}

function gameConnection::onClientLeaveGame(%this)
{
CityRPData.saveData(%this);
CityRPData.getData(%this.bl_id).delete();

if(%this.player)
{
for(%a = 0; %a < %this.player.getDatablock().maxTools; %a++)
{
if(!%tools)
{
%tools = %this.player.tool[%a];
}
else
{
%tools = %tools SPC %this.player.tool[%a];
}

}

CityRPData.getData(%this.bl_id).valueTools = %tools;
}

parent::onClientLeaveGame(%this);
}

welcome to 2014

use json