Try to make something where when you cut wood, you get logs and xp. When you get 10 xp, you level up and it displays your level. Use this as an example. Made by Mr. Wallet.
//a hammer called the wood-choppin' axe that only kills trees and adds to a client's .wood field.
//supplying the actual models, fleshing out the projectile data to something less hammer-y, making it act like a weapon in minigames,
//making the woodcutting USEFUL for something, etc., is left as an exercise to the interested reader.
datablock ItemData(WoodAxeItem : HammerItem)
{
//shapeFile = "./WoodAxe.dts";
uiName = "Wood-Choppin' Axe";
//iconName = "./icon_WoodAxe";
// Dynamic properties defined by the scripts
image = WoodAxeImage;
};
datablock ProjectileData(WoodAxeProjectile : HammerProjectile)
{
uiName = "Axe Swing";
};
datablock ShapeBaseImageData(WoodAxeImage : HammerImage)
{
//shapeFile = "./WoodAxe.dts";
item = WoodAxeItem;
projectile = WoodAxeProjectile;
};
function WoodAxeImage::OnFire(%this, %obj, %slot)
{
HammerImage::OnFire(%this, %obj, %slot);
}
function WoodAxeImage::onHitObject(%this, %player, %a, %brick, %particle, %f)
{
if(!%brick.isplanted) return; //prevents console spam if not hitting a brick object, since things like terrain and interiors don't have a ::getdatablock()
if(%brick.getdatablock().getname() $= "brickPineTreeData" && gettrustlevel(%player, %brick) >= 2) {
HammerImage::OnHitObject(%this, %player, %a, %brick, %particle, %f);
%player.client.wood++;
messageclient(%player.client, "", "\c2LOL you now has " @ %player.client.wood @ " wood.");
}
}
//PUT THIS IN A PACKAGE
function armor::OnCollision(%this, %obj, %col, %pos, %a)
{
if(!%obj.client.isadmin && %col.datablock $= "WoodAxeItem") return;
parent::OnCollision(%this, %obj, %col, %pos, %a);
}
//DEVELOPMENT PROCESS:
//After defining the basic image I went through a stuffstorm of echoes, traces, and dumps. I was even trying to code my own raycast for the hit, for a while.
//after about 45 minutes from the start of the project, I realized that the game didn't care if I just called hammerimage's onfire, which like the wrench and the wands results in an "onhitobject" result.
//the moral of the story is that if you try to make something different from anything you've made before, no matter how experienced you are, you've got some studying ahead.
Also try to use Block City mod. That could be helpful.