Author Topic: [Snippet] Load a Save on a Dedicated Server in Less then 5 Seconds *  (Read 1193 times)

For those that don't want to make their own saving system like Nix did, here is a alternative to loading a save on a dedicated server.  The host is required to have the save.

Code: [Select]
function serverCmdquickLoad(%client, %saveFile)
{
   if(%client.isSuperAdmin == false)
   {
    return; 
   }
   %saveFile = strReplace(%saveFile, "SPC", " ");
   if(isFile(findFirstFile("saves/*/" @ %saveFile @ ".bls")) == false) {
   error("quickLoad() => File Not Found.");
   return;
   }
     %saver = new FileObject();
     %file = new FileObject();
     %file.openForWrite("base/server/temp/temp.bls");
     %file.writeLine("This is a Blockland save file.  You probably shouldn't modify it cause you'll screw it up.");
     %file.openForRead(findFirstFile("saves/*/" @ %saveFile @ ".bls"));
     %saver.openForAppend("base/server/temp/temp.bls");
      while(!%file.isEOF())
      {
     %line = %file.readLine();
     if(%line !$= "This is a Blockland save file.  You probably shouldn't modify it cause you'll screw it up.")
     {
     %saver.writeLine(%line);
     }
   }
  %file.close();
  %file.delete();
  %saver.close();
  %saver.delete();
  serverCmdReloadBricks(%client);
}

This actually seems useful.

Could be simplified a bit, but I agree with Chrono on it's usefulness.

Why do you need to write the line first and then check against every line to make sure it isn't that one?

Clearly he doesn't know what he's doing.

Do this is working ? I think not ?