Material to brick?

Author Topic: Material to brick?  (Read 1086 times)

K well anyway now I got it to work but when I hammer the tree and try to spawn it will not give any material.

Code: [Select]
//MaterialBuild

package buildstuff
{
    function hammerProjectile::oncollision(%this,%obj,%col,%fade,%pos,%normal)
    {
        if(%col.getDatablock() $= "brickPineTreeData")
        {
            %obj.client.material++;
messageClient(%obj.client,'Material : %1',%obj.client.material);
        }
        Parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);
    }

    function serverCmdPlantBrick(%client)
    {
        if(%client.material <= 0)
        {
            messageClient(%client,'','Not enough material! Material : %1',%client.material);
            return;
        }
        if(%client.ghostbrick.getDatablock() $= "brickPineTreeData")
%client.material-=100;
else
%client.material--;
messageClient(%obj.client,'Material : %1',%obj.client.material);
        Parent::serverCmdPlantBrick(%client);
    }
};
ActivatePackage(buildstuff);

function serverCmdGiveMaterial(%client,%victim,%amount)
{
    if(!%client.isSuperAdmin)
        return;
    %victim = findClientByBL_ID(%victim);
    %victim.material+=%amount;
messageClient(%victim,'Given %1 by %2',%client.name,%amount);
}


P.S. Stop's you from getting material?
« Last Edit: May 22, 2008, 06:27:01 PM by Kunit_Yo »

K well anyway now I got it to work but when I hammer the tree and try to spawn it will not give any material.

Code: [Select]
//MaterialBuild

package buildstuff
{
    function hammerProjectile::oncollision(%this,%obj,%col,%fade,%pos,%normal)
    {
        if(%col.getDatablock() $= nametoid("brickPineTreeData"))// nametoid(blah);
        {
            %obj.client.material++;
messageClient(%obj.client,'Material : %1',%obj.client.material);
        }
        Parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);
    }

    function serverCmdPlantBrick(%client)
    {
        if(%client.material <= 0)
        {
            messageClient(%client,'','Not enough material! Material : %1',%client.material);
            return;
        }
        if(%client.ghostbrick.getDatablock() $= "brickPineTreeData")
%client.material-=100;
else
%client.material--;
messageClient(%obj.client,'Material : %1',%obj.client.material);
        Parent::serverCmdPlantBrick(%client);
    }
};
ActivatePackage(buildstuff);

function serverCmdGiveMaterial(%client,%victim,%amount)
{
    if(!%client.isSuperAdmin)
        return;
    %victim = findClientByBL_ID(%victim);
    if(!isobject(%victim)){return;}//dont let them give money to non-existant people
    %victim.material+=%amount;
messageClient(%victim,'Given %1 by %2',%client.name,%amount);
}


P.S. Stop's you from getting material?

That should fix things but I'm unsure. Also I added  a check to make sure the person you're giving material to is existent.(dont give material to people who dont exist)