OK so i have stole most of this from cashmodII (thanks clockturn) and it seems to only save the words "mr Accs" from if(!isFile("config/server/mrCash.txt"))
{
%FO.openForWrite("config/server/mrCash.txt");
%FO.writeline("mr Accs");
%FO.close();
}
It won't save my clients id or cash? I have been playing with it for hours and it am getting no where. Hoping you guys can see an easy flaw. The script contains echos. The result when it runs is: echos 3 - 9 and also displays saved from the bottom (messageClient(%client,'',"Saved");)
package mrWorldSave {
function GameConnection::onClientEnterGame(%client) {
Parent::onClientEnterGame(%client);
schedule(1500, 0, relay1, %client);
}
};
activatePackage(mrWorldSave);
function relay2(%client)
{
schedule(1500, 0, GameSave, %client);
schedule(1500, 0, relay1, %client);
}
function relay1(%client)
{
schedule(1500, 0, relay2, %client);
}
function GameSave(%client) {
//read to write
%FO = new FileObject("FO");
if(!isFile("config/server/mrCash.txt"))
{
%FO.openForWrite("config/server/mrCash.txt");
%FO.writeline("mr Accs");
%FO.close();
}
if(%FO.openForRead("config/server/mrCash.txt"))
{
%FO.readline();
//active users
while(!%FO.isEOF())
{
echo(1);
%temp[%lines] = %FO.readLine();
if(getField(%temp[%lines],0) == %client.ID)
{
echo(2);
%temp[%lines] = %client.ID TAB %client.Cash;
%found = 1;
}
%lines++;
}
//new users
echo(3);
if(!%found)
{echo(4);
%temp[%lines] = %client.ID TAB %client.Cash;
%lines++;
}
echo(5);
%FO.close();
}
//write
echo(6);
for(%i=0;%i<%lines;%i++)
{echo(7);
%FO.writeline(%temp[%i]);
}
%FO.close();
echo(8);
%FO.delete();
echo(9);
messageClient(%client,'',"Saved");
}