48
« on: March 21, 2013, 07:34:43 AM »
So, as of v21, when I plant the brick in the air, it will still call the onPlant function even though the brick itself did not plant. This causes some bad errors to happen.
Here's my onPlant code if necessary:
function fxDTSBrickData::OnPlant( %this, %obj )
{
parent::onPlant( %this, %obj );
if( %this.isOre || %this.isTree )
{
%obj.resources = %this.resources;
%obj.health = %this.maxHealth;
}
%client = %obj.getGroup().client;
if( isObject( %obj ) )
{
if( %this.adminOnly )
{
if( %client.isAdmin )
{
return;
}
else
{
commandToClient( %client, 'centerPrint', "\c6You are not permitted to plant this brick.", 2 );
%obj.schedule(0, "delete");
return;
}
}
if( %client.buildMode )
{
return;
}
%player = %client.player;
%found = false;
for( %i = 0; %i < %player.getDataBlock().maxTools; %i++ )
{
if( %player.tool[ %i ].getName() $= "gmsHammerItem" )
{
%found = true;
}
}
if( !%found )
{
commandToClient( %client, 'centerPrint', "\c6You must have a building hammer to build!", 2 );
%obj.schedule(0, "delete");
return;
}
%req = MCeil( ( %this.brickSizeX * %this.brickSizeY * %this.brickSizeZ ) * (60/100) );
if( %req > 1024 )
{
commandToClient( %client, 'centerPrint', "\c6This brick cannot be planted.", 2 );
%obj.schedule(0, "delete");
return;
}
if( %client.resources["wood"] < %req )
{
commandToClient( %client, 'centerPrint', "\c6You need\c3" SPC %req SPC "\c6wood to plant this brick.", 2 );
%obj.schedule(0, "delete");
}
else
{
commandToClient( %client, 'centerPrint', "\c6You planted a brick for\c3" SPC %req SPC "\c6wood.", 2 );
%client.resources["wood"] -= %req;
%client.strandedBottomPrint();
%obj.cost = %req;
}
}
}
Any idea how to resolve this problem?