Author Topic: Messing with baseplate rules...  (Read 1286 times)

Ok i need the codes from baseplates so people can't plant with out a lot. I skimmed through the server.cs and found this:

Code: [Select]
%plantedBrick = %client.brickGroup.getObject(%client.brickGroup.getCount() - 1);
if(%plantedBrick.getDistanceFromGround() == 0 && %plantedBrick.getDatablock().category !$= "Baseplates")
{
%plantedBrick.delete();
commandToClient(%client,'MessageBoxOK',"Invalid Brick","You must start with a Baseplate.<bitmap:base/client/ui/brickIcons/16x16 Base>");
}

So i went ahead and pasted it into my own server.cs and it didn't work. So i put it some callbacks so it now looks like this:

Code: [Select]
%plantedBrick = %client.brickGroup.getObject(%client.brickGroup.getCount() - 1);
if(%plantedBrick.getDistanceFromGround() == 0 && %plantedBrick.getDatablock().category !$= "Baseplates")
{
%plantedBrick.delete();
commandToClient(%client,'MessageBoxOK',"Invalid Brick","You must start with a Baseplate.<bitmap:base/client/ui/brickIcons/16x16 Base>");
return;
} else {
messageClient(%client,'',%plantedBrick.getDistanceFromGround() @ %plantedBrick.getDatablock().category);
}

The result will message the client the "distance from the ground" SPC "category". The result: 2147483647 Bricks

Post your whole function for your version. Some variables may not have been mentioned, which is why it's not a smart idea to copy-paste code.


   function serverCmdPlantBrick(%client)
   {
      parent::serverCmdPlantBrick(%client);
      if($Pref::Server::BREnable == 2)
      {
         if(%client.bl_id == getNumKeyID())
            return;
         if($Pref::Server::BRAppliesToAdmin == 1 && %client.isSuperAdmin)
            return;
         if($Pref::Server::BRAppliesToAdmin == 2 && %client.isAdmin)
            return;
         if(%client.BRException)
            return;
         %plantedBrick = %client.brickGroup.getObject(%client.brickGroup.getCount() - 1);
         if(%plantedBrick.getDistanceFromGround() == 0 && %plantedBrick.getDatablock().category !$= "Baseplates")
         {
            %plantedBrick.delete();
            commandToClient(%client,'MessageBoxOK',"Invalid Brick","You must start with a Baseplate.<bitmap:base/client/ui/brickIcons/16x16 Base>");
         }
      }
   }
« Last Edit: June 12, 2011, 07:20:33 PM by tyler0 »


are you setting $Pref::Server::BrAppliesToAdmin and $Pref::Server::BREnable to a boolean or a value? If it's a boolean, that's not the problem, but if it's not you'd have to use $="#" instead of == #.

   function serverCmdPlantBrick(%client)
   {
      parent::serverCmdPlantBrick(%client);
      if($Pref::Server::BREnable == 2)
      {
         if(%client.bl_id == getNumKeyID())
            return;
         if($Pref::Server::BRAppliesToAdmin == 1 && %client.isSuperAdmin)
            return;
         if($Pref::Server::BRAppliesToAdmin == 2 && %client.isAdmin)
            return;
         if(%client.BRException)
            return;
         %plantedBrick = %client.brickGroup.getObject(%client.brickGroup.getCount() - 1);
         if(%plantedBrick.getDistanceFromGround() == 0 && %plantedBrick.getDatablock().category !$= "Baseplates")
         {
            %plantedBrick.delete();
            commandToClient(%client,'MessageBoxOK',"Invalid Brick","You must start with a Baseplate.<bitmap:base/client/ui/brickIcons/16x16 Base>");
         }
      }
   }

That doesnt match what you originally posted.

Also - this is slightly easier use:
Code: [Select]
function serverCmdPlantBrick(%client)
  {
   %plantedBrick = parent::serverCmdPlantBrick(%client);
   if (!isObject(%plantedBrick) )
     return;

   if ($Pref::Server::BREnable == 2)
     {
      if(%client.bl_id == getNumKeyID())
        return;
      if($Pref::Server::BRAppliesToAdmin == 1 && %client.isSuperAdmin)
        return;
      if($Pref::Server::BRAppliesToAdmin == 2 && %client.isAdmin)
        return;
      if(%client.BRException)
        return;

      if (%plantedBrick.getDistanceFromGround() == 0 && %plantedBrick.getDatablock().category !$= "Baseplates")
        {
         %plantedBrick.delete();
         commandToClient(%client,'MessageBoxOK',"Invalid Brick","You must start with a Baseplate.<bitmap:base/client/ui/brickIcons/16x16 Base>");
        }
     }
  }

but what do you mean "it doesnt work" ?

what happens when you plant a baseplate on the ground?
what happens when you plant a non-baseplate on the ground?
what happens when you plant a non-baseplate on a baseplate?

Code: [Select]
function serverCmdPlantBrick(%client) {
%plantedBrick = parent::serverCmdPlantBrick(%client);

if(%plantedBrick.getDistanceFromGround() == 0 && %plantedBrick.getDatablock().category !$= "Baseplates") {
%plantBrick.delete();
commandToClient(%client,'MessageBoxOK',"Invalid Brick","You must start with a Baseplate.<bitmap:base/client/ui/brickIcons/16x16 Base>");
}
}

It works.. just is doesn't cancel the parent::serverCmdPlantBrick?

Code: [Select]
Entering [mrBrickSystem]serverCmdPlantBrick(7369)
   Entering serverCmdPlantBrick(7369)
      Entering fxDTSBrick::onAdd(10895)
« Last Edit: June 13, 2011, 10:52:06 PM by tyler0 »

2147483647 Bricks
That's the highest number that binary can get.
[nope.avi]
« Last Edit: June 17, 2011, 01:28:03 AM by YoshiDude »

That's the highest number that binary can get.
[/nerd]
Yeah, no. It's the highest number a 32 bit integer can reach.

Yeah, no. It's the highest number a 32 bit integer can reach.
A signed 32 bit integer, if I remember correctly.

Lol ok thanks but why doesn't it cancel the parent?

Lol ok thanks but why doesn't it cancel the parent?
So it deletes the brick but echoes that in the console? Try returning -1. That means that no object was created.

A signed 32 bit integer, if I remember correctly.
Editing post and removing [/nerd].