As far as the actual brick planting...
Found in a post not too long ago and used it for one of my projects.
%brick = new fxDtsBrick()
{
position = position;
dataBlock = datablock;
colorID = color;
client = client;
};
%brick.setTrusted(1);
%brick.isPlanted = 1;
%brick.plant();
Make sure you change position, datablock, colorid, and client to match what you need.
and then use %player.tempbrick.getDatablock() for the datablock
As for other things to make it just like the brick planting tool, I don't know. Your best bet is to do what other people have already said - look at the swiss army gun. Use that as a resource to figure a few things out. Of course you can't just copy and paste it and expect it to work.