• 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!

Solved [T.F.S 1.0] Farming code

The Doctor

Time Lord
Joined
Mar 15, 2014
Messages
7
Reaction score
0
Location
Universe
I am trying to set this up on my server, but the second part of the codes does not seem to work for me.
Following this: http://otland.net/threads/farming-mining-woodcutting-updated-fletching-scripts.82419/

I am just using the farming part:
farming.lua
hoesoil.lua
harvest plants.lua
and I copied the XML actions

Code:
local cfg = {
soul = 1,
level = 10
}
local t = {
[{4006}] = {fruit = 2675, NFTree = 4008, amount = 3, fName = "Orange"},
[{5094}] = {fruit = 2676, NFTree = 5092, amount = 3, fName = "Banana"},
[{5096}] = {fruit = 2678, NFTree = 2726, amount = 3, fName = "Coconut"},
[{5157}] = {fruit = 5097, NFTree = 5156, amount = 3, fName = "Mango"}
}
function onUse(cid, item, frompos, item2, topos)
local S = getPlayerSoul(cid)
local L = getPlayerLevel(cid)
for i, k in pairs(t) do
if (isInArray(i, item.itemid) == true) and (S >= cfg.soul) and (L >= cfg.level) then
doTransformItem(item.uid, k.NFTree)
doPlayerAddItem(cid, k.fruit, k.amount)
doPlayerAddSoul(cid, -cfg.soul)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got some "..k.fName..".")
elseif (S < cfg.soul) then
doPlayerSendCancel(cid, "You do not have soul to harvest the plant.")
elseif (L < cfg.level) then
doPLayerSendCancel(cid, "You are not in the requiered level to harvest.")
end
end
end

The first two files work fine and there is nothing wrong. Its the "harvest plants.lua" that is not working for me. I tried to fix it by doing a few things but none seemed to work.
 
No error on console. Well from what I understand, the most important aspects of the code is that when you click "use" in tibia. When you click "use" on a item it is supposed to check if the item ID (a fruiting fruit tree) matches the ones it has stored in the array. If it does, it is supposed to change the "tree" back into its non fruiting form (NFTree) and then give the player a fruit (fName) according to the Id that it checked with the "use". It also check your level and soul to make sure you can perform this action and removes soul as you perform it. As of now, it only says " You cannot use this object" and does not do anything. One thought is that maybe it does not know where to place the replacement tree, but then why wont it let me click "use". I guess the main problem is that it wont let the code run because the "use" is unsuccessful.
 
How did you added it in actions.xml?
The script is missing return true above the last end btw, but that's not the reason why it doesn't do anything.
 
I hope the format is right. I tried to find one similar to compare but didn't have any luck.
Code:
<action itemid="5157;4006;5094;5096" event="script" value="harvest plants.lua"/>
 
Code:
<action itemid="4006" script="other/harvest plants.lua"/>
<action itemid="5094" script="other/harvest plants.lua"/>
<action itemid="5096" script="other/harvest plants.lua"/>
<action itemid="5157" script="other/harvest plants.lua"/>
 
Back
Top