75
« on: June 16, 2008, 09:43:56 PM »
Ok well I made some code that save's all the junk for my rpg but is what happen's is you don't get 1 of a material and you spawn it will load the save file as =; which causes a syntax therefore crashing after 3 people spawn if they have been there before. So I made some code to try to add 1 on connect but it doesn't add any and no syntax's
package Add
{
function GameConnection::onconnect(%client,%a,%b,%c,%d,%e,%f){
if(%client.minigame)
%obj.client.quantity["Copperore"] += 1;
%obj.client.quantity["Goldore"] += 1;
%obj.client.quantity["Silverore"] += 1;
%obj.client.quantity["Pinewood"] += 1;
%obj.client.quantity["Oakwood"] += 1;
%obj.client.quantity["Maplewood"] += 1;
Parent::onconnect(%client,%a,%b,%c,%d,%e,%f);
}
};
ActivatePackage(Add);
Saving
package Savzorz
{
function GameConnection::onClientEnterGame(%this)
{
Parent::onClientEnterGame(%this);
exec("Add-ons/RPG/Rpgbank/" @ %this.bl_id @ ".RPGData");
%this.RPG["ISSPAWNED"] = 1;
}
function SaveRPGData(%Client)
{
if(%client.RPG["ISSPAWNED"] == 0)
return;
%file = new FileObject();
%file.openforwrite("Add-ons/RPG/Rpgbank/" @ %client.bl_id @ ".RPGData");
%file.writeline("findclientbybl_id(" @ %client.bl_id @ ").quantity[\"CopperOre\"] = " @ %client.quantity["CopperOre"] @ ";");
%file.writeline("findclientbybl_id(" @ %client.bl_id @ ").quantity[\"SilverOre\"] = " @ %client.quantity["SilverOre"] @ ";");
%file.writeline("findclientbybl_id(" @ %client.bl_id @ ").quantity[\"GoldOre\"] = " @ %client.quantity["GoldOre"] @ ";");
%file.writeline("findclientbybl_id(" @ %client.bl_id @ ").quantity[\"PineWood\"] = " @ %client.quantity["PineWood"] @ ";");
%file.writeline("findclientbybl_id(" @ %client.bl_id @ ").quantity[\"OakWood\"] = " @ %client.quantity["OakWood"] @ ";");
%file.writeline("findclientbybl_id(" @ %client.bl_id @ ").quantity[\"MapleWood\"] = " @ %client.quantity["MapleWood"] @ ";");
%file.writeline("findclientbybl_id(" @ %client.bl_id @ ").quantity[\"Gold\"] = " @ %client.quantity["Gold"] @ ";");
%file.close();
%file.delete();
}
function autoSaveRPGData()
{
for(%x=0; %x < clientgroup.getcount(); %x++)
{
SaveRPGData(clientgroup.getobject(%x));
}
schedule(120000,0,autoSaveRPGData);
}
};
activatePackage("Savzorz");
schedule(120000,0,autoSaveRPGData);