If you post code, at least bother to post code that doesn't have a design flaw in it. This is code that I used to manage building in a arctic survival RPG that I was making, but haven't the will to continue. (Note that this is only the building part, the rest of my code isn't shown here)
function checkbrick(%obj)
{
switch(%obj.colorid)
{
case 0: %type="wood";
case 1: %type="stone";
case 2: %type="ice";
case 3: %type="raw_meat";
case 4: %type="meat";
case 5: %type="snow";
default: %type = "admin";
}
%x = %obj.getdatablock().bricksizex;
%y = %obj.getdatablock().bricksizey;
%z = %obj.getdatablock().bricksizez;
%vol = %x * %y * %z;
%client = %obj.client;
%amount = %client.resource[%type];
if(%type $= "snow")
{
if( %x > 2 )
{
commandtoclient(%client,'centerprint', "\c6That brick is too large to be made out of snow.", 3);
%obj.killbrick();
}
else if( %y > 4 )
{
commandtoclient(%client,'centerprint', "\c6That brick is too large to be made out of snow.", 3);
%obj.killbrick();
}
else if( %z > 6 )
{
commandtoclient(%client,'centerprint', "\c6That brick is too large to be made out of snow.", 3);
%obj.killbrick();
}
return;
}
if(%type $= "admin")
{
if(!%client.issuperadmin)
{
%obj.killbrick();
}
return;
}
if(%vol > %amount)
{
commandtoclient(%client,'centerprint', "Not enough" SPC %type @ "!", 3);
%obj.killbrick();
return;
}
%client.resource[%type]= %client.resource[%type] - %vol;
if($messagestep==2)
{
messagecurrentstock(%client);
}
}
package buildingrestrictions
{
function GameConnection::createPlayer(%this,%t)
{
Parent::createPlayer(%this,%t);
resetstock(%this);
}
function fxDTSBrick::onToolBreak(%obj, %client)
{
switch(%obj.colorid)
{
case 0: %type="wood";
case 1: %type="stone";
case 2: %type="ice";
case 3: %type="raw_meat";
case 4: %type="meat";
default: %type = "none";
}
%x = %obj.getdatablock().bricksizex;
%y = %obj.getdatablock().bricksizey;
%z = %obj.getdatablock().bricksizez;
if( %type !$= "none")
{
gather(%client, %x * %y * %z, %type);
}
Parent::onToolBreak(%obj, %client);
}
function fxDTSBrick::onPlant(%this,%brick)
{
Parent::onPlant(%this,%brick);
schedule(10,0,checkbrick, %this);
}
function servercmdUseSprayCan(%client,%num)
{
servercmdcancelbrick(%client);
%client.currentcolor= %num;
switch(%num)
{
case 0: %type="wood";
case 1: %type="stone";
case 2: %type="ice";
case 3: %type="raw meat";
case 4: %type="meat";
case 5: %type="snow";
default: %type="admin";
}
if( %type $= "admin")
{
commandtoclient(%client,'centerprint', "\c6This paint is \c0ADMIN ONLY!", 3);
}
else
{
commandtoclient(%client,'centerprint', "\c6Currently building with \c2" SPC %type @ "\c6.", 3);
}
}
function servercmdUseFxCan(%client, %num)
{
commandtoclient(%client,'centerprint', "\c6Use of the Fx can is disabled.", 3);
return;
}
};
activatepackage(buildingrestrictions);
The code will have to be changed to work for you (since allot of this is stuff needed for my RPG specifically), but a combination of what Ephi and I posted will work.
There is probably a better way, but I don't know it, so if you want it, you'll have to figure it out yourself.