function fxDTSBrick::onPlant(%brick)
{
// Stating a variable for returning the
// parent so nothing is messed up when
// adding this code onto onPlant.
%r = Parent::onPlant(%brick);
// Get the client from the brick.
%client = %brick.getGroup().client;
// Check if the client's Credits are
// NOT greater than the required cost.
// If they aren't then the client shouldn't
// be able to plant the brick!
if(%client.Credits < $BrickCost)
{
// Since the client doesn't meet the
// requirements to plant the brick,
// message the client that he couldn't
// place the brick, delete the brick
// and return/exit the function.
commandToClient(%client, 'centerPrint', "Insufficient Credits!", 3);
%brick.schedule(0, "delete");
return %r;
}
// Your stuff that you want to happen
// when the brick is properly planted.
%client.Credits -= $BrickCost;
$Treasury += $BrickCost;
// Instead of returning %r you could
// just return 'Parent::onPlant(%brick)'
// but since they both return the same
// thing (%r being declared above), it
// doesn't matter. I personally find using
// 'return %r' to be more organized and
// easier. It's just a choice of preference.
// =========================================
// Exit the function, allowing the default
// Blockland onPlant code and other code
// from other packages to execute.
return %r;
}