Author Topic: Help with Confusing Syntax Error!  (Read 1037 times)

Please help me with this syntax error! It's very confusing.

you forgot the closing " in the last messageClient parameter


Don't lock any more of your threads

You know you could just not parent it and give them a message if they are not an admin instead of destroying the brick.

This code is such a horrible mess which wouldn't even work if the missing " issue was solved. Here, let me point out a few of the flaws:

Quote
package NoBaseplates
{
function FxBTSBrick::OnPlant(%client, %this)
{
parent::OnPlant(%client, %this);
   %brick = %this; // Why would you even do this? The brick is available from %this, no need for an extra variable.
   if(%client.isAdmin)
      return;
       if(!(%brick.getType() & $TypeMasks::FxBrickAlwaysObjectType))
         if(!%brick.isPlanted)
// What the hell is the point of the this? The brick will never not brick, and will never not placed. In fact, this will cause it to never define %brickData unless somebody is running this function on a namespace basis.

         %brickData = %brick.getDataBlock().getID();
         if(%brickData.category $= "Baseplates")
            {
               %brick.killBrick();
          MessageClient(%this, '', "\c6Non-admins aren't allowed to plant any bricks in the baseplate section.");
          }
}
};
ActivatePackage(NoBaseplates);

Here are some hints:
  • The arguments for the fxDTSBrickData::onPlant callback are the brick datablock, %this, and the brick object, %obj.
  • You can access the client of a brick by getting it's brick group using getBrickGroupFromObject( object ) and accessing it's .client field.
  • The previously mentioned function is called when the brick is planted. There is no need to check whether it's planted.
« Last Edit: March 21, 2012, 11:59:39 AM by Port »

Port is correct, aside from this:

  • The previously mentioned function is called when the brick is planted. There is no need to check whether it's planted.

The fxDtsBrick::onPlant function is also called when a temp brick is placed. %brick.isPlanted checks whether the brick is a temp brick or not, so it is in fact something that should be included.

The fxDtsBrick::onPlant function is also called when a temp brick is placed. %brick.isPlanted checks whether the brick is a temp brick or not, so it is in fact something that should be included.

What are you talking about? fxDTSBrick::plant() only calls fxDTSBrick::onPlant() upon successfully placing the brick. Try it yourself.

package test { function fxDTSBrick::onPlant( %this ) { announce ( "onPlant( " @ %this @ " )" ); parent::onPlant( %this ); } };
activatePackage( "test" );

Evaluate those two lines in the console and place a brick.


Anyway, I don't know anything about this. Adam Savage coded this.
« Last Edit: March 22, 2012, 06:52:33 AM by ScratchTehEPICSpaceDude »

Anyway, I don't know anything about this. Adam Savage coded this.
Then why isn't he getting off his lazy ass and asking the question himself?

Then why isn't he getting off his lazy ass and asking the question himself?

I'm not sure his "lazy ass" is on the forums.
« Last Edit: March 23, 2012, 12:39:44 PM by ScratchTehEPICSpaceDude »



This code is such a horrible mess which wouldn't even work if the missing " issue was solved. Here, let me point out a few of the flaws:

Here are some hints:
  • The arguments for the fxDTSBrickData::onPlant callback are the brick datablock, %this, and the brick object, %obj.
  • You can access the client of a brick by getting it's brick group using getBrickGroupFromObject( object ) and accessing it's .client field.
  • The previously mentioned function is called when the brick is planted. There is no need to check whether it's planted.

Omg, you're right. It doesn't work. Sorry, can you send me a fixed server.cs? I'm not a good coder.