Author Topic: Syntax Error [EDIT: CONSOLE ERROR]  (Read 1196 times)

Every time I try to run this script I keep on getting (the same) syntax errors. I would greatly appreciate it if you could help. Console.log Snip:

Syntax solved, see second post.

Here is the whole code.

Quote
package BrickPlant {
   function serverCmdPlantBrick(%this)
   {
      $CodeNextBrick=1;
      parent::serverCmdPlantBrick(%this);
   }
   function fxDTSbrick::onPlant(%brick)
   {
      %ret = parent::onPlant(%brick);
      %client = %brick.client;
      if(!$codeNextBrick)
      return %ret;
            if(isObject(%brick.getDownBrick(0)))
          {
         if(%brick.getDownBrick.getDatablock() $= nametoid("Admin32x32x1Data"))
             {
          if(getTrustLevel(%client,%brick.getDownBrick(0) == 0) || getTrustLevel(%client,%brick.getDownBrick(0) == 1) || getTrustLevel(%client,%brick.getDownBrick(0) == 2))
           {
                if(%client.isSuperAdmin || %client.isAdmin)
                 {
         
                  %brick = %client.player.tempBrick;
                  %pos = %brick.getPosition();

                  %newBrick = new fxDtsBrick()
                  {
                     position  = %pos;
                     rotation  = %brick.rotation;
                     dataBlock = %brick.getDataBlock();
                     angleId   = %brick.angleId;
                     colorId   = %brick.colorId;
                     colorFxId = %brick.colorFxId;
                     shapeFxId = %brick.colorFxId;
                     client    = %client;
                  };

                  %newBrick.plant();
                  %newBrick.setTrusted(1);
                  %client.brickGroup.add(%newBrick);
                        }
             }
         }
   return %ret;
      }
    }
 };
activatepackage(brickplant);

package PlatePlant {
   function serverCmdPlantBrick(%this)
   {
      $CodeNextBrick=1;
      parent::serverCmdPlantBrick(%this);
   }
   function fxDTSbrick::onPlant(%brick)
   {
      %ret = parent::onPlant(%brick);
      %client = %brick.client;
      if(!$codeNextBrick)
      return %ret;
         
      if(!isObject(%client.player.tempBrick))
       {
         if(%client.player.tempBrick.GetDataBlock() $=Nametoid ("Admin32x32x1Data"))
           {
              if(%client.isSuperAdmin || %client.isAdmin)
              {
                  %brick = %client.player.tempBrick;
                  %pos = %brick.getPosition();

                  %newBrick = new fxDtsBrick()
                  {
                     position  = %pos;
                     rotation  = %brick.rotation;
                     dataBlock = %brick.getDataBlock();
                     angleId   = %brick.angleId;
                     colorId   = %brick.colorId;
                     colorFxId = %brick.colorFxId;
                     shapeFxId = %brick.colorFxId;
                     client    = %client;
                  };
                  %newBrick.plant();
              %newbrick.setTrusted(1);
              %client.brickGroup.add(%newBrick);
                        }
                 }
   return %ret;
      }
    }
  };
Activatepackage(plateplant);

« Last Edit: July 22, 2010, 02:50:59 AM by Miles Barlow »

Quote
     else
        {
          parent::servercmdplantbrick(%client, %brick);
        }
Needs a semicolon there.

Specifically you need one if you're calling a function (as you have there), setting a variable (%vec = "10 10 10";) or creating an object. (new fxDTSBrick(){...};)
« Last Edit: July 21, 2010, 04:49:43 AM by Space Guy »

Needs a semicolon there.
Oh, thanks for the quick reply :D! I'll test it out now.

EDIT2: I changed the script (updated OP), but it still checks for trust. I think this has something to do with this console error every time I plant a brick.

Quote
Add-Ons/Brick_AdminPlates/server.cs (14): Unable to find object: '' attempting to call function 'getDownBrick'
BackTrace: ->[adminbrick]ServerCmdPlantBrick->[adminplates]ServerCmdPlantBrick


Add-Ons/Brick_AdminPlates/server.cs (15): Unable to find object: '' attempting to call function 'getDataBlock'
BackTrace: ->[adminbrick]ServerCmdPlantBrick->[adminplates]ServerCmdPlantBrick
« Last Edit: July 21, 2010, 05:44:55 AM by Miles Barlow »

Your script thinks the person sends them the brick. The server makes the brick. If the client could make brick data, then tell the server "Okay, my brick is this", then it might as well be able to tell it's in someone else's build and laugh.

Edit: I'm saying that, when you plant a brick, the server handles creation of the brick on the ghost brick information. All that's sent is %client.
« Last Edit: July 21, 2010, 11:33:32 AM by MegaScientifical »

maybe mess around with brickgroups to get this to work

serverCmdPlantBrick only has one variable, client. If you want to get info about the planted brick, I suggest doing something like this:

Code: [Select]
package BrickPlant {
function serverCmdPlantBrick(%this)
{
$CodeNextBrick=1;
parent::serverCmdPlantBrick(%this);
}
function fxDTSbrick::onPlant(%brick)
{
%ret = parent::onPlant(%brick);
%client = %brick.client;
if(!$codeNextBrick)
return %ret;
$CodeNextBrick=0;
if(%brick.getDownBrick(0).getDatablock().getName() $= "Admin32x32x1Data" && !%client.isAdmin)
{
%brick.delete();
messageClient(%client,'',"You must be an admin to build there!");
return;
}
return %ret;
      }
  };

I just kinda pasta'd your code onto the end there, so I'm assuming that works.


EDIT: I finally figured out what you were trying to do, and updated my code so that it would work.
« Last Edit: July 22, 2010, 03:55:12 AM by Triple Nickels »

You should put the brick check in plantbrick and look up what his ghostbrick is.

UPDATED CODE IN OP

Thanks for the help all you guys, I believe the %downbrick problem was fixed, but this still appears in the console every time I plant a brick; there seems to be a problem with getDataBlock.
Quote
Add-Ons/Brick_AdminPlates/server.cs (73): Unable to find object: '' attempting to call function 'getDataBlock'
BackTrace: ->[PlatePlant]ServerCmdPlantBrick->[BrickPlant]ServerCmdPlantBrick->[DeletionBricks]ServerCmdPlantBrick->[JVS_Content]ServerCmdPlantBrick->[duplicator]ServerCmdPlantBrick->[SAG_MoveMode]ServerCmdPlantBrick->ServerCmdPlantBrick->[VCE_Main]fxDTSBrick::onPlant->[PlatePlant]fxDTSBrick::onPlant


Add-Ons/Brick_AdminPlates/server.cs (24): Unable to find object: '' attempting to call function 'getDataBlock'
BackTrace: ->[PlatePlant]ServerCmdPlantBrick->[BrickPlant]ServerCmdPlantBrick->[DeletionBricks]ServerCmdPlantBrick->[JVS_Content]ServerCmdPlantBrick->[duplicator]ServerCmdPlantBrick->[SAG_MoveMode]ServerCmdPlantBrick->ServerCmdPlantBrick->[VCE_Main]fxDTSBrick::onPlant->[PlatePlant]fxDTSBrick::onPlant->[BrickPlant]fxDTSBrick::onPlant


restart blockland

leave coding help and never come back please

Thanks for the help Triple Nickels, but I still get this console error:

Quote
Add-Ons/Brick_AdminPlates/server.cs (25): Unable to find object: '' attempting to call function 'getDataBlock'
BackTrace: ->[PlatePlant]ServerCmdPlantBrick->[DeletionBricks]ServerCmdPlantBrick->[JVS_Content]ServerCmdPlantBrick->[duplicator]ServerCmdPlantBrick->[SAG_MoveMode]ServerCmdPlantBrick->ServerCmdPlantBrick->[VCE_Main]fxDTSBrick::onPlant->[PlatePlant]fxDTSBrick::onPlant


Add-Ons/Brick_AdminPlates/server.cs (25): Unable to find object: '' attempting to call function 'getName'
BackTrace: ->[PlatePlant]ServerCmdPlantBrick->[DeletionBricks]ServerCmdPlantBrick->[JVS_Content]ServerCmdPlantBrick->[duplicator]ServerCmdPlantBrick->[SAG_MoveMode]ServerCmdPlantBrick->ServerCmdPlantBrick->[VCE_Main]fxDTSBrick::onPlant->[PlatePlant]fxDTSBrick::onPlant

I'm not asking for a whole new script, but I do need help fixing these errors.

By now, if you haven't learned, I'll just have to yell it at you: Dude, read what the errors are instead of asking us to give you the simple translation. Every error you've posted is saying you're trying to do commands on nothing. Obviously something doesn't exist you're trying to check. Look where those commands are used and see if what it's trying to be used on is defined.

OK, I'll lock it for know while I work it out.