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

Farming error

lorpo

Mapper/Scripter
Joined
Dec 20, 2008
Messages
17
Reaction score
0
Oi,
I got a farming script on my server and everything is going well except that if my plant withers it says the MSG 2x instead of once and it gives the following error in my console (TFS 0.3.6pl1 console)

PHP:
[Error - Action Interface]
In a timer event called from:
data/actions/scripts/other/farming.lua:onUse
Description:
<luaDoRemoveItem> Item not found

This is the farming.lua code:
PHP:
local config = {
	grounds = {804},
	sMin = 2
	}
	--To add more plants to grow just copy this example:
	--[{XXXX}] = {NFTree = XXXX, bloomInSec = XX, t_DthInSec = XX, FTree = XXXX, tname = ""},--
	--Ref: NFTree = Non Fruit Tree, FTree = Fruit Tree, bloomInSec = time that it takes to bloom, t_DthInSec = time that it takes for plant to die,
	--tname = tree name and [{XXXX}] = Seed(fruit) itemid, all XXXX are itemids--
	--and paste it under:
local t = { --HERE--
		[{2677}] = {NFTree = 2786, bloomInSec = 60, t_DthInSec = 30, FTree = 2785, tname = "blueberry bush"},
		[{5097}] = {NFTree = 5156, bloomInSec = 120, t_DthInSec = 60, FTree = 5157, tname = "mango tree"},
		[{2676}] = {NFTree = 5093, bloomInSec = 120, t_DthInSec = 60, FTree = 5094, tname = "banana tree"}
		}
function onUse(cid, item, fromPosition, itemEx, toPosition) 
local soul = getPlayerSoul(cid)
		for i, k in pairs(t) do
				if (isInArray(i, itemEx.itemid) == true) and itemEx.type == 1 and (soul >= config.sMin) then 
local ground_position = {x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 0}
local ground_information = getThingfromPos(ground_position)
						if(isInArray(config.grounds, ground_information.itemid) == TRUE) then
							doPlayerAddSoul(cid, -config.sMin)
							doTransformItem(itemEx.uid, k.NFTree)
							doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your "..k.tname.." has grown!")
							addEvent(Bloom, k.bloomInSec*1000, {position = toPosition, cid = cid, t_Dth = k.t_DthInSec})
 
						else
							doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This is not the proper ground for farming.")
						end	
				elseif(soul < config.sMin) then
					doPlayerSendCancel(cid, "You do not have enough soul to farm.")
				elseif(itemEx.type ~= 1) then
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You may only grow one plant at a time.")
				end		
			end
  return TRUE
end
function Bloom(parameter)
 
local tree = getThingfromPos{x = parameter.position.x, y = parameter.position.y, z = parameter.position.z, stackpos = 1}
	for i, k in pairs(t) do
		if (tree.itemid == k.NFTree) then
			doTransformItem(tree.uid, k.FTree)
			doPlayerSendTextMessage(parameter.cid, MESSAGE_INFO_DESCR, "Your "..k.tname.." has fully grown! Harvest it before it withers!")
			addEvent(t_Die, parameter.t_Dth*1000, {position = {x = parameter.position.x, y = parameter.position.y, z = parameter.position.z }, cid = parameter.cid})
		end
	end
end	
function t_Die(parameter)
	
local tree = getThingfromPos{x = parameter.position.x, y = parameter.position.y, z = parameter.position.z, stackpos = 1}
	for i, k in pairs(t) do
		if (tree.itemid == k.NFTree or k.FTree) then	
			doRemoveItem(tree.uid)
			doPlayerSendTextMessage(parameter.cid, MESSAGE_INFO_DESCR, "Your crop has withered.")
		end		
	end			
end

Hope any1 can find the errors and solve them, I will rep++ once i'm able to
 
I can't test it maybe:
change the last part of script with this:
Code:
function t_Die(parameter) 
     
local tree = getThingfromPos({x = parameter.position.x, y = parameter.position.y, z = parameter.position.z, stackpos = 1})
    for i, k in pairs(t) do 
        if (tree.itemid == k.NFTree or k.FTree) then     
            doRemoveItem(tree.uid,1) 
            doPlayerSendTextMessage(parameter.cid, MESSAGE_INFO_DESCR, "Your crop has withered.") 
        end         
    end             
end
 
nothing changes, i always keep getting the same errors, but well it's not that it affects the gameplay :D only disturbs me lol.. So yea, if u would find the solution you can always tell me, but it's ok :) thx for the help
 
Back
Top