Author Topic: Loading a build/cycle  (Read 865 times)

Code: [Select]
function JB_LoadMap_Phase1(%filename) {
%fileName = "Add-Ons/GameMode_Jailbreak/src/maps/" @ %fileName @ ".bls";
   //put everyone in observer mode
for(%i = 0; %i < clientGroup.getCount(); %i++) {
%client = clientGroup.getObject(%i);
%player = %client.player;
if(isObject(%player))
%player.delete();

%camera = %client.camera;
%camera.setFlyMode();
%camera.mode = "Observer";
%client.setControlObject(%camera);
   }
   
BrickGroup_2143.chaindeletecallback = "JB_LoadMap_Phase2(\"" @ %filename @ "\");";
BrickGroup_2143.chaindeleteall();
}

function JB_LoadMap_Phase2(%filename) {
echo("Loading jailbreak map " @ %filename);

%displayName = %filename;
%displayName = strReplace(%displayName, "Add-Ons/GameMode_Jailbreak/src/maps/", "");
%displayName = strReplace(%displayName, ".bls", "");
%displayName = strReplace(%displayName, "_", " ");

%displayName = "\c6Loading Map - \c3" @ %fileName;
   
if(%fileName $= "Gefangnis")
%displayName = %displayName @ "\c6, created by \c3Skill4Life";
if(%fileName $= "Desert")
%displayName = %displayName @ "\c6, created by \c3Niblic";

announce(%displayName);
schedule(10, 0, serverDirectSaveFileLoad, %fileName, 3, "", 1, 1);
}

Basically ripped from the speedkart gamemode, I'm trying to load a build which works but I'm wondering if there is a way to detect when the build has loaded so I can reset the minigame. Or if there is a better way to do this, I'd just rather not have people running around while the builds are clearing/loading.

Package ServerLoadSaveFile_End()

also from speedkart:

Code: [Select]
package GameModeSpeedKartPackage
{
   //...
   //when we're done loading a new track, reset the minigame
   function ServerLoadSaveFile_End()
   {
      Parent::ServerLoadSaveFile_End();

      //new track has loaded, reset minigame
      if($DefaultMiniGame.numMembers > 0) //don't bother if no one is here (this also prevents starting at round 2 on server creation)
         $DefaultMiniGame.scheduleReset(); //don't do it instantly, to give people a little bit of time to ghost

      SK_ResetSelf DeleteGambling();
   }
  //...
};

already answered but I'M POSTING IT ANYWAY AND YOU CAN'T STOP ME

Oh it's that easy? I should've looked at the rest of the code lol. Thanks.

Also, you should probably make a separate list for your credits displaying that you have going on in JB_LoadMap_Phase2 instead of a bunch of if statements if that's what you're going to do.

Also, you should probably make a separate list for your credits displaying that you have going on in JB_LoadMap_Phase2 instead of a bunch of if statements if that's what you're going to do.
Alternately at least clean it up with a switch statement and use fileName:

Code: [Select]
%displayName = strReplace(fileName(%fileName), "_", " ");
%displayName = getSubStr(%displayName, 0, strLen(%displayName)-strLen(fileExt(%fileName)));

switch$(%fileName) {
case "Gefangnis":
    %authorName = "Skill4life";
case "Desert":
    %authorName = "Niblic";
}

announce("\c6Loading Map - \c3" @ %fileName @ "\c6, created by \c3" @ %authorName);
« Last Edit: April 10, 2015, 02:54:01 PM by $trinick »