Author Topic: Canceling Parents??  (Read 584 times)

Why doesn't this cancel the parent when it rejects the brick cost?


package BrickBuyingSystem {
   function fxDTSBrick::onPlant(%brick, %client) {
      %brickGroup = getBrickGroupFromObject(%brick);
      %client = %brickGroup.client;
      %brickdb = %brick.getDatablock();
      %brickvol = (%brickdb.getVolume() * 2);
      
      if(%brickdb == %rareBrick) {
         
         
      } else {
         if(%client.cash >= %brickvol) {
            
            messageClient(%client,'',"\c2Bought Brick - \c6Cost: $" @ %brickvol);
            %client.cash -= %brickvol;
            Parent::onPlant(%brick);
         } else {
            
            messageClient(%client,'',"Can't Afford This Brick. \c6Cost: $" @ %brickvol);
            return;
         }

      }
   }
};
activatepackage(BrickBuyingSystem);

I think the issue might be onplant is called after the brick is planted.  Instead, you could do a schedule for 0ms to delete it, because just deleting it there can really mess up alot of things.

I think the issue might be onplant is called after the brick is planted.  Instead, you could do a schedule for 0ms to delete it, because just deleting it there can really mess up alot of things.
Yes.
EDIT: If you want to make it less hacky when you plant something and its deleted (if you try to plant lots of bricks quickly you can see it being deleted) package serverCmdPlantBrick.