Author Topic: Calling vars when bricks are planted  (Read 694 times)

I am having trouble about how to go about integrating variables for the client when a brick a placed i want to know what the function will be so for example

When they place a specific brick.
In this case when they place a lumbermill brick

%Client.LMCount++;
So next time i can call a function that acts as a resource up for the entire server
%Client.Wood += %Client.LMCount * %Client.LMBonus

I also want to know how do i set varables for a player when they spawn since i cant get access to the server files.

I could tell you, but no thanks.

Do this:

1. Go in game with no add-ons enabled.
2. Open console, submit trace(1);
3. Close console.
4. Plant a brick.
5. Open console.
6. trace(0);
7. Examine the spam that was output.
8. Find the function yourself. It's somewhere in there.

I'll be a little more help than Iban and tell you that you will need a package in order to detect when functions are called to do something else.

package mypackage
{
   function myfunction(%vars)
   {
      parent::myfunction(%vars);

      //Now that you know the function has been called, what will happen?
   }
};
activatepackage(mypackage);

all bricks
Code: [Select]
function fxDTSBrickData::onPlant(%this)certain bricks
Code: [Select]
function BRICKNAMEHERE:onPlant(%this)

Code: [Select]
function fxDtsBrick::onPlant(%data,%brick)
{



if(%brick.getDatablock().ChosenResource $= "Wood")
{
%brick.setColor("50");
MessageAll('',"An Lumbermill has been constructed!");
}

if(%brick.getDatablock().ChosenResource $= "Iron")
{
%brick.setColor("48");
MessageAll('',"An Iron Mine has been constructed!");
}


}
This is where I got up to I'm just trying to increment a client variable from there now.
Would i need to find the client by using something like FindClientByID?

no, just do, I believe, %brick.client and that will reference the client that planted the brick.

Oh wow thanks man! It works :)!