Blockland Forums > Modification Help

Help with gamemode.

Pages: (1/2) > >>

Eeposs:

Can someone spiff up this code to work... i've been having trouble.



--- Code: ---datablock fxDtsBrickData(plastic : brick2x2Data)
   {
      category = "Gamemode"; //Category of the brick ( the tab when you press B )
      subCategory = "Resources"; //Sub category, like baseplates, Cubes or Water
      uiname = "Plastic"; //The name of the brick
      isPlastic = true; //Just to say this brick is plastic
      mintime = 60; //Minimum time to respawn
      maxtime = 90; //Maximum time to respawn
   };
   datablock projectileData(shaperProjectile : swordProjectile)
   {
   directDamage        = 0; //Makes projectile of the sword hit for 0 instead of sword's
   };
  
   datablock shapeBaseImageData(shaperImage : swordImage)
   {
        item = shaperItem;
        
        projectile = shaperProjectile;
        
        projectileType = Projectile;
        
        colorShiftColor = "0.750 0.750 0.750 1.000000";
   };
  

   datablock itemData(shaperItem : swordItem)
   {
        uiName = "Plastic Shaper"; //Name to be displayed on BL
        
        image = shaperImage;
        
        colorShiftColor = "0.750 0.750 0.750 1.000000";
   };
package PlasticGamemode
{
   //The following is just to make the animations, don't mess with it
   function shaperImage::onFire(%datablock, %obj, %slot)
   {
        Parent::onFire(%datablock, %obj, %slot);
        
        %obj.playThread(2, "armAttack");
   }

   function shaperImage::onStopFire(%this, %obj, %slot)
   {
        %obj.playThread(2, "root");
   }
   //End of animation part

   function hammerProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)(%this, %obj, %col, %fade, %pos, %normal) //When the projectile collides with something...(it can or not be a brick)
   {
      %client = %obj.sourceObject.client; //We get the client who hit with the plastic shaper
      if(%col.getClassName() $= "fxDTSBrick")
      {
         %db = %col.getDatablock(); //%db is now equal to the datablock of the brick
         if(%db.isPlastic)
         {
            //If it's plastic...
            onHit(%client,%col,%db); //%client is the client, %col is the brick and %db is the datablock of the brick
            serverPlay3D(wrenchHitSound, %pos);
         }
         else
         {
            //If it's not...
            commandToClient(%client,'centerPrint',"<color:ffffff>This is not plastic!",3);
         }
      }
      else
      {
         //If it's not a brick...
         commandToClient(%client.client,'centerPrint',"<color:ffffff>Use the plastic shaper on plastic brick",3);
      }
   }
   function onHit(%client,%brick,%brickdb) //When the plastic is hit...%client is the client that hit it %brick is the plastic brick and %brickdb is the datablock of the brick
   {
      if(%brick.percent >= 100)
      {
         commandToClient(%client,'centerPrint',"<color:ffffff>You gained 5 plastic for shaping this plastic!",3);
         %client.plastic += 5; //Adds 5 plastic to the client
         %brick.disappear(30); //Makes the brick disappear for 30secs, so you can't click it or do anything, just like disappear event
         %brick.percent = 0; //Makes the brick be 0% completed
         %brick.setColor(getRandom(0,8)); //Makes the brick a random color between 0 and 8 (the ID)
         bottomPrint(%client); //Update bottomPrint
      }
      else
      {
         %brick.percent += 5; //Adds 5 to percent, making the brick +5% completed.
         commandToClient(%client,'centerPrint',"<color:ffffff>You hit the unshaped plastic\n<color:ffff00>"@%brick.percent@"% completed!",3,2); //Displays that you hit the brick and how much % completed.
         if(%brick.percent >= 100)
            onHit(%client,%brick,%brickdb); //If it's already 100% or over, we don't want to say it's 100% completed, so we do it like if you hitted with the plastic shaper again
      }
   }
   //When a brick is planted. Please note that this makes a bug with loading, which is pretty hard to fix, so I made an hacky fix
   function FxDtsBrick::onPlant(%brick)
   {
      if(!$Loading)
         schedule(5330,0,"checkBrick",%brick); //Go thru the brick and do our checks
      return parent::onPlant(%brick); //return the onPlant stuff so it actually makes the bricks.
   }
   function checkBrick(%brick)
   {
      %client = %brick.client; //We find the client on the brick
      %brickdb = %brick.getDatablock(); //We get the datablock of the brick
      if(%brickdb.isPlastic) //If the brick is plastic...
      {
         if(%client.isSuperAdmin)
         {
            %brick.percent = 0; //We make it have 0% completed, so it starts at 0% instead of [blank]%
            %brick.setColor(getRandom(0,8));
         }
         else //If it's not SA
            %brick.killBrick();
         return;
      }
      else if(%client.plastic >= 1)
      {
         //We are good, take off plastic
         %client.plastic--;
         bottomPrint(%client); //Update bottomPrint
         commandToClient(%client,'centerPrint',"<color:ffffff>You made a brick, but it costed you<color:ffff00>1 <color:ffffff>plastic",3);
      }
      else //If the client has less than 1 plastic...
      {
         %brick.killBrick();
         commandToClient(%client,'centerPrint',"<color:ffffff>You need to have atleast <color:ffff00>1 <color:ffffff>plastic to plant this brick!",3);
      }
   }
   function bottomPrint(%client)
   {
      //Bottomprints the plastic count
      commandToClient(%client,'bottomPrint',"<color:ffffff>Plastic: <color:ffff00>"@%client.plastic);
   }
};
activatePackage(PlasticGamemode);
--- End code ---


Greek2me:

You need to define shapeFile as the path to your model and image as the item image in the item datablock.

Eeposs:


--- Quote from: Greek2me on September 25, 2011, 07:47:31 PM ---You need to define shapeFile as the path to your model and image as the item image in the item datablock.

--- End quote ---
Ugh broken

Eeposs:

BUMP

phflack:

function hammerProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)(%this, %obj, %col, %fade, %pos, %normal) //When the projectile collides with something...(it can or not be a brick)
seems like "(%this, %obj, %col, %fade, %pos, %normal)" is duplicated

Pages: (1/2) > >>

Go to full version