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

Fixing script

Status
Not open for further replies.

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,764
Solutions
1
Reaction score
227
Location
Chile, Santiago
Hi, I have this script:
LUA:
local function createTree(p)

doCreateItem(2722,1,{x=32857, y=32231, z=11})
doCreateItem(2722,1,{x=32857, y=32232, z=11})
doCreateItem(2722,1,{x=32857, y=32233, z=11})

end

function onAddItem(moveitem, tileitem, pos)

tree1pos = {x=32857, y=32231, z=11, stackpos=1} -- postion tree 1
tree2pos = {x=32857, y=32232, z=11, stackpos=1} -- postion tree 2
tree3pos = {x=32857, y=32233, z=11, stackpos=1} -- postion tree 3
tree1 = getThingfromPos(tree1pos)
tree2 = getThingfromPos(tree2pos)
tree3 = getThingfromPos(tree3pos)

if (moveitem.itemid == 6300 or moveitem.itemid == 6301) then
    doRemoveItem(moveitem.uid,1)
    doSendMagicEffect(pos,2)

    local function intenalRemoveItem(pos)
        local t = getThingfromPos(pos).uid
        if (t > 0) then
            return doRemoveItem(t) and intenalRemoveItem(pos)
        end    
    end
    
    intenalRemoveItem(tree1pos)
    intenalRemoveItem(tree1pos)
    intenalRemoveItem(tree3pos)
    

    doSendMagicEffect(tree1pos,7)
    doSendMagicEffect(tree2pos,7)
    doSendMagicEffect(tree3pos,7)
    p = {treeid = tree1.itemid}
    addEvent(createTree, 15*1000, p)

else
end
return 1
end

It works nice, but it doesnt remove all items over the ground, especially the second tree, could someone help on this?

I rep++!
 
LUA:
local items = {
    [2722] = {x=32857, y=32231, z=11},
    [2722] = {x=32857, y=32232, z=11},
    [2722] = {x=32857, y=32233, z=11}
}

local function createTree()
    for itemid, pos in pairs(items) do
        doCreateItem(itemid, 1, pos)
    end
end
 
function onAddItem(moveitem, tileitem, pos)
    if (moveitem.itemid == 6300 or moveitem.itemid == 6301) then
        doRemoveItem(moveitem.uid,1)
        doSendMagicEffect(pos,2)
 
        for itemid, pos in pairs(items) do
             local item = getTileItemById(pos, itemid)
             if(item.uid > 0) then
                 doRemoveItem(item.uid)
                 doSendMagicEffect(pos, 7)
             end
        end

        addEvent(createTree, 15*1000)
    end
    return true
end
 
Last edited:
Code:
local items = {
[COLOR="red"]    [2722] = {x=32857, y=32231, z=11}
    [2722] = {x=32857, y=32232, z=11}
    [2722] = {x=32857, y=32233, z=11}[/COLOR]
}

local function createTree()
    for itemid, pos in pairs(items) do
        doCreateItem(itemid, 1, pos)
    end
end
 
function onAddItem(moveitem, tileitem, pos)
    if (moveitem.itemid == 6300 or moveitem.itemid == 6301) then
        doRemoveItem(moveitem.uid,1)
        doSendMagicEffect(pos,2)
 
        for itemid, pos in pairs(items) do
             local item = getTileItemById(pos, itemid)
             if(item.uid > 0) then
                 doRemoveItem(item.uid)
                 doSendMagicEffect(pos, 7)
             end
        end

        addEvent(createTree, 15*1000)
    end
    return true
end

Comma's!

Here is fixed version.

Code:
local items = {
	[2722] = {x = 32857, y = 32231, z = 11},
	[2722] = {x = 32857, y = 32232, z = 11},
	[2722] = {x = 32857, y = 32233, z = 11}
}

function onAddItem(moveitem, tileitem, pos)
	if moveitem.itemid == 6300 or moveitem.itemid == 6301 then
		doRemoveItem(moveitem.uid,1)
		doSendMagicEffect(pos,2)
		
		for itemid, pos in pairs(items) do
			local item = getTileItemById(pos, itemid)
			if item.uid > 0 then
				doRemoveItem(item.uid)
				doSendMagicEffect(pos, 7)
			end
		end

		local v = items[item.itemid]
		addEvent(function() doCreateItem(v, 1, v[2]) end, 15 * 1000)
	end

	return true
end
 
Comma's!

Here is fixed version.

Code:
local items = {
	[2722] = {x = 32857, y = 32231, z = 11},
	[2722] = {x = 32857, y = 32232, z = 11},
	[2722] = {x = 32857, y = 32233, z = 11}
}

function onAddItem(moveitem, tileitem, pos)
	if moveitem.itemid == 6300 or moveitem.itemid == 6301 then
		doRemoveItem(moveitem.uid,1)
		doSendMagicEffect(pos,2)
		
		for itemid, pos in pairs(items) do
			local item = getTileItemById(pos, itemid)
			if item.uid > 0 then
				doRemoveItem(item.uid)
				doSendMagicEffect(pos, 7)
			end
		end

		local v = items[item.itemid]
		addEvent([b][color="red"]function() doCreateItem(v, 1, v[2]) end[/color][/b], 15 * 1000)
	end

	return true
end
wont work
 
Status
Not open for further replies.
Back
Top