Author Topic: Adding bricks to minigame  (Read 1596 times)

Basically, I have a script that automatically creates an AIConnection, a BrickGroup, loads a save and creates a minigame. The AIConnection is set as the owner of the minigame, that seems to work. However, whenever I place a brick and place it in the AIConnection's BrickGroup it still doesn't accept the brick into the minigame. Trying to add the AIConnection to the minigame doesn't work because it's discriminative and only accepts human players.
« Last Edit: October 02, 2011, 09:35:43 PM by DontCare4Free »

Try setting %brick.owner to the aiConnection.

Try setting %brick.owner to the aiConnection.
Still not working.

1. Set the minigame's owner to the aiConnection.
2. Set the aiConnection's brickgroup to the brickgroup you created.
3. Set the brickgroup's client to the aiConnection.
4. Make sure the bricks you've created belong to that brickgroup.

1. Set the minigame's owner to the aiConnection.
2. Set the aiConnection's brickgroup to the brickgroup you created.
3. Set the brickgroup's client to the aiConnection.
4. Make sure the bricks you've created belong to that brickgroup.
This is basically what I've already done. And no, it still doesn't work.

Make sure to set the brickgroup's client variable.

Is there a %brick.minigame or %brickgroup.minigame var?

Make sure to set the brickgroup's client variable.
Did. Issue persists.

Is there a %brick.minigame or %brickgroup.minigame var?
No.

This is basically what I've already done. And no, it still doesn't work.
Post your code :|

Post your code :|
Code: (server.cs) [Select]
$ServerMaint::Time = "10"; //Tick Time in mins.

function ServerMaint_Init()
{
   exec("config/server/servermaint.cs");
   ServerMaint_Load();
   $ServerMaint::Tick = true;
   ServerMaint_Tick();
   warn("Auto Saver Initialising");
}

function ServerMaint_Load(%savenum) {
        if (%savenum $= "") %savenum = $ServerMaint::SaveCount;
        announce("Loading backup number" SPC %savenum @ ".");
        %path = "saves/Slate/CityRP/Backup_" @ %savenum @ ".bls";
        if (true) { // fileExists(%path)) {
                fileCopy(%path, "base/server/temp/temp.bls");
                if (!isObject($ServerMaint::FauxClient)) $ServerMaint::FauxClient = new AIConnection() {
                        name = "Server";
                        bl_id = 1337;
                        isAdmin = true;
                };

                if (isObject(BrickGroup_1337)) $ServerMaint::FauxClient.brickGroup = BrickGroup_1337;
                else {
                        $ServerMaint::FauxClient.brickGroup = new simGroup(BrickGroup_1337) {
                                name = "Server";
                                bl_id = 1337;
                        };
                        mainBrickGroup.add($ServerMaint::FauxClient.brickGroup);
                }
BrickGroup_1337.client = $ServerMaint::FauxClient;
                serverCmdReloadBricks($ServerMaint::FauxClient);
        }

        if (isObject($ServerMaint::Minigame)) {
                $ServerMaint::Minigame.endGame();
                $ServerMaint::Minigame.delete();
        }

        for (%i=0;%i<clientGroup.getCount();%i++) {
                %cl = clientGroup.getObject(%i);
                if (isObject(%cl.minigame)) {
                        %cl.minigame.endGame();
                        %cl.minigame.delete();
                }
        }

        $ServerMaint::Minigame = new ScriptObject() {
                owner = $ServerMaint::FauxClient;
                ownerBL_ID = 1337;
                brickDamage = false;
                class=miniGameSO;
                colorIdx = 9;
                EnableBuilding = true;
                EnablePainting = true;
                enableWand = true;
                fallingdamage = false;
                inviteOnly = false;
                numMembers = 1;
                playerDataBlock = PlayerNoJet;
                PlayersUseOwnBricks = false;
                Points_BreakBrick = 0;
                Points_Die = 0;
                Points_KillPlayer = 0;
                Points_KillSelf = 0;
                Points_PlantBrick = 0;
                respawnTime = 1000;
                SelfDamage = false;
                StartEquip0 = 0;
                StartEquip1 = 0;
                StartEquip2 = 0;
                StartEquip3 = 0;
                StartEquip4 = 0;
                Title = "City RP";
                useAllPlayersBricks = false;
                useSpawnBricks = true;
                VehicleDamage = true;
                vehicleReSpawnTime = 0;
                weaponDamage = true;
        };

        for(%i=0;%i<clientGroup.getCount();%i++) {
                %cl = clientGroup.getObject(%i);
                $ServerMaint::Minigame.addMember(%cl);
        }
        activatePackage(ServerMaint_Minigame);
}

package ServerMaint_Minigame {
        function GameConnection::spawnPlayer(%this) {
                parent::spawnPlayer(%this);

                if (isObject($ServerMaint::Minigame) && %this.minigame != $ServerMaint::Minigame) {
                        $ServerMaint::Minigame.addMember(%this);
                }
        }

        function servercmdleaveminigame() {}
        function servercmdcreateminigame() {}
};

function serverCmdAutoSave(%client)
{
   if(!%client.issuperadmin) return;
   if(!$ServerMaint::Tick)
   {
      announce("Activating Auto-Saver");
      $ServerMaint::Tick = true;
      ServerMaint_Tick();
      return;
   }
   cancel($ServerMaint::Schedule);
   $ServerMaint::Tick = false;
   announce("Deactivating Auto-Saver");
}

function ServerMaint_Tick()
{
   cancel($ServerMaint::Schedule);
   if(!$ServerMaint::Tick)
   {
      return;
   }

   $ServerMaint::SaveCount++;
   $ServerMaint::Schedule = schedule($ServerMaint::Time * 1000 * 60, 0, ServerMaint_Tick);
   export("$ServerMaint::SaveCount", "config/server/servermaint.cs");

   ServerMaint_DoStuff();
}

function ServerMaint_DoStuff()
{
   announce("\c7 Maintenance Tick Initiating...");
   %filename = "CityRP/Backup_" @ $ServerMaint::SaveCount;
   saveBricks(%filename, true, true);
   announce("\c7 - Saved Bricks (" @ $ServerMaint::SaveCount @ "," SPC getBrickCount() SPC "bricks)");
}

schedule(0, 0, ServerMaint_Init);
« Last Edit: October 03, 2011, 11:42:08 AM by DontCare4Free »

This is a somewhat less hacky way of loading bricks, and it might solve your problem, too.
Code: [Select]
$LoadingBricks_BrickGroup = $ServerMaint::FauxClient.brickgroup;
$LoadingBricks_Client = $ServerMaint::FauxClient;
$LoadingBricks_ColorMethod = 3; //should always be 3
$LoadingBricks_DirName = MissionInfo.saveName;
$LoadingBricks_DoOwnership = true;
$LoadingBricks_FileName = %path;
$LoadingBricks_Silent = true;
$LoadingBricks_StartTime = getSimTime();
ServerLoadSaveFile_Start(%path);

This is a somewhat less hacky way of loading bricks, and it might solve your problem, too.
Code: [Select]
$LoadingBricks_BrickGroup = $ServerMaint::FauxClient.brickgroup;
$LoadingBricks_Client = $ServerMaint::FauxClient;
$LoadingBricks_ColorMethod = 3; //should always be 3
$LoadingBricks_DirName = MissionInfo.saveName;
$LoadingBricks_DoOwnership = true;
$LoadingBricks_FileName = %path;
$LoadingBricks_Silent = true;
$LoadingBricks_StartTime = getSimTime();
ServerLoadSaveFile_Start(%path);
The loading is working fine and isn't the problem at hand.