• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

woodcuting help

redbull915

I learn...
Joined
Oct 10, 2008
Messages
235
Reaction score
0
Location
Poland/Radom
Welcome i created woodcuting system, but it's not like I wanted, for that filed the request for help with writing a very similar system which appears on the movie link below along with the script already written.

Movie: YouTube - Kingdom Age - WoodCuting System!

Lua:
local config = {
	trees = {2701,2702,2703,2704,2705,2706,2707,2708,2709,2710,2712,2717,2718,2720,2722},
	skill = "Woodcutting",
	addTries = 3023,
	branches = 8786,
	item = 5901,
	amount = 1,
	effect = CONST_ME_BLOCKHIT,
	msgType = MESSAGE_EVENT_ADVANCE,
	sounds = {"Pock", "Pec", "Tck"},
	seconds = 5
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isInArray(config.trees, itemEx.itemid) then
		local itemid, timeSound = itemEx.itemid, 1.1
		for i = 1, 10 do
			addEvent(function()
				doSendAnimatedText(toPosition, config.sounds[math.random(1, table.maxn(config.sounds))], COLOR_LIGHTGREEN)
			end, (i*timeSound) * 1000, {toPosition = toPosition})
			chance = math.random(100)
		end
			if chance <= 80 then
				doPlayerSendTextMessage(cid, config.msgType, "Not found.")
				return true
			elseif chance > 80 then
				doRemoveItem(getThingFromPos(toPosition).uid)
				doSendMagicEffect(toPosition, CONST_ME_HITAREA or config.effect) 
				doCreateItem(config.branches, 1, toPosition)
				addCustomSkillTry(cid, config.skill, config.addTries)
				doPlayerAddItem(cid, config.item, config.amount)
				addEvent(function()
					doRemoveItem(getThingFromPos(toPosition).uid)
					doSendMagicEffect(toPosition, 45)
					doCreateItem(2769, 1, toPosition)
					addEvent(function()
						doRemoveItem(getThingFromPos(toPosition).uid)
						doSendMagicEffect(toPosition, 45)
						doCreateItem(2768, 1, toPosition)
						addEvent(function()
							doRemoveItem(getThingFromPos(toPosition).uid)
							doSendMagicEffect(toPosition, 45)
							doCreateItem(itemid, 1, toPosition)
						end, config.seconds * 1000, {itemid = itemid, toPosition = toPosition})
					end, config.seconds * 1000, {itemid = itemid, toPosition = toPosition})
				end, config.seconds * 1000, {itemid = itemid, toPosition = toPosition})
			end
	else
		doPlayerSendTextMessage(cid, config.msgType, "Either this tree can't be choped.")
	end
	return true
end
 
Here is similar scrpit but have less function:
Lua:
  <?xml version="1.0" encoding="UTF-8"?>
<mod name="WoodCuting System" version="1.0" author="Karpio" contact="http://tibia.net.pl/members/karpio.html" enabled="yes">
<config name="WoodCuting Lib"><![CDATA[
wood = {}
wood.reward = 5901
wood.trees = {2700, 2701, 2702, 2703, 2704, 2705, 2706, 2707, 2708}
wood.maxLevel = 100
wood.stor = {876, 875}
wood.showLevel = true
function wood.getPlayerSkill(cid)
        return getPlayerStorageValue(cid, wood.stor[1])
end
function wood.addSkillTry(cid)
        if(getPlayerStorageValue(cid, wood.stor[1]) >= wood.maxLevel) then
                return true
        end
        local formula = getPlayerStorageValue(cid, wood.stor[1]) / 10
        if(math.random(1, formula) == 1) then
                if(getPlayerStorageValue(cid, wood.stor[2]) >= 99) then
                        setPlayerStorageValue(cid, wood.stor[2], 0)
                        setPlayerStorageValue(cid, wood.stor[1], getPlayerStorageValue(cid, wood.stor[1])+1)
                        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You advanced in WoodCuting. "..(wood.showLevel == true and "["..getPlayerStorageValue(cid, wood.stor[1]).."]" or "").."")
                else
                        setPlayerStorageValue(cid, wood.stor[2], getPlayerStorageValue(cid, wood.stor[2])+1)
                end
        end
return true
end
]]></config>
<action itemid="2559" event="script"><![CDATA[
        domodlib("WoodCuting Lib")
        function onUse(cid, item, fromPosition, itemEx, toPosition)            
                if(isInArray(wood.trees, itemEx.itemid) == false) then
                        return false
                end
                wood.addSkillTry(cid)
                doSendMagicEffect(toPosition, 16)              
                if(math.random(wood.getPlayerSkill(cid), wood.maxLevel) == wood.maxLevel) then
                        local itemid = itemEx.itemid
                        doRemoveItem(itemEx.uid, 1)
                        doPlayerAddItem(cid, wood.reward, 1)
                        doCreateItem(8786, 1, toPosition)
                        addEvent(function()
                                doRemoveItem(getThingFromPos(toPosition).uid)
                                pien = doCreateItem(2768, 1, toPosition)
                                addEvent(function()
                                        doRemoveItem(getThingFromPos(toPosition).uid)
                                        doCreateItem(itemid, 1, toPosition)
                                end, 5 * 1000, {itemid = itemid, toPosition = toPosition})
                        end, 5 * 1000, {itemid = itemid, toPosition = toPosition})
                end
        return true
        end]]></action>
<event type="login" name="WoodCuting Login" event="script"><![CDATA[
        domodlib("WoodCuting Lib")
        function onLogin(cid)
                if(getPlayerStorageValue(cid, wood.stor[1]) < 10) then
                        setPlayerStorageValue(cid, wood.stor[1], 10)
                end
                if(getPlayerStorageValue(cid, wood.stor[2]) < 0) then
                        setPlayerStorageValue(cid, wood.stor[2], 0)
                end
        return true
        end
]]></event>
</mod>
Save this in OTS/mods/woodCuting.xml.
P.S. It working on TFS 0.3.6. And to cut the tree you need small axe :p
 
Here is something i cooked up it should work the way you want it, and also remember to read the little comments inside the scripts and configure it:
Lua:
local cfg =  {
    trees = {2701,2702,2703,2704,2705,2706,2707,2708,2709,2710,2712,2717,2718,2720,2722},
	tree = {
		[{1, 100}] = {tree = 2701},
		[{101, 200}] = {tree = 2702},
		[{201, 300}] = {tree = 2703},
		[{301, 400}] = {tree = 2704},
		[{401, 500}] = {tree = 2705},
		[{501, 600}] = {tree = 2706},
		[{601, 700}] = {tree = 2707},
		[{701, 800}] = {tree = 2708},
		[{801, 900}] = {tree = 2709},
		[{901, 1000}] = {tree = 2710},
		[{1001, 1100}] = {tree = 2712},
		[{1101, 1200}] = {tree = 2717},
		[{1201, 1300}] = {tree = 2718},
		[{1301, 1400}] = {tree = 2720},
		[{1401, 1500}] = {tree = 2722}
		},
    skill = "Woodcutting",
    addTries = 5,
    branches = 8786,
    item = 5901,
    amount = 1,
    effect = CONST_ME_BLOCKHIT,
    msgType = MESSAGE_EVENT_ADVANCE,
	sounds = {
		[{1, 100}] = {"Pock"},
		[{101, 200}] = {"Pec"},
		[{201, 300}] = {"Tck"}
		},
    seconds = 5
}
function onUse(cid, item, toPosition, itemEx, fromPosition)
	if item.itemid == xxxx then -- xxxx = axe itemid here --
		if isInArray(cfg.trees, itemEx.itemid) then
			if math.random(1, (100 + (getCustomSkill(cid, xxxxx) / 10))) <= getCustomSkill(cid, xxxxx)*2 then -- change the xxxxx to the storage value of that custome skill --
				doCreatureSetNoMove(cid, true)
				addEvent(reTry, cfg.seconds*1000, {cid = cid, item = item, toPosition = toPosition, itemEx = itemEx, fromPosition = fromPosition})
				
				local function reTry()
					local chance = math.random(1, 1000)
					for i, k in pairs(cfg.sound) do
						if chance <= 700 then
							local v = math.random(300)
							if v >= i[1] and v <= i[2] then
								doSendAnimatedText(toPosition, 18, k)
								doSendMagicEffect(toPosition, cfg.effect)
								addCustomSkillTry(cid, config.skill, config.addTries)
								addEvent(reTry, cfg.seconds*1000, {cid = cid, item = item, toPosition = toPosition, itemEx = itemEx, fromPosition = fromPosition})
							end
						elseif chance > 700 and chance <= 900 then
							doPlayerAddItem(cid, cfg.item, cfg.amount)
							doTransformItem(itemEx.uid, cfg.branches)
							doCreatureSetNoMove(cid, false)
							addEvent(reGrow, 15*1000, {cid = cid, item = item, toPosition = toPosition, itemEx = itemEx, fromPosition = fromPosition})
						elseif chance > 900 then
							doPlayerSendTextMessage(cid, 25, "You found nothing.")
							doCreatureSetNoMove(cid, false)
						end
					end
				end
				local function reGrow()
					getTree = getThingfromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 1})
					if getTree.itemid == cfg.branches then
						for trees, t in pairs(cfg.tree) do
							local val = math.random(1500)
							if val >= trees[1] and val <= trees[2] then
								if t.tree then
									doSendMagicEffect(toPosition, 50)
									doTransformItem(getTree.uid, t.tree)
								end
							end
						end
					end
				end
				
			else
				doPlayerSendCancel(cid, "You swang and missed.")
				addCustomSkillTry(cid, config.skill, config.addTries)
			end	
		end
	end
return true
end
if it works enjoy if it doesn't then I'm sorry. :p
 
Back
Top