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

[Request] Lua script to open hidden holes desert

Jester

Off
Senator
Joined
May 28, 2007
Messages
2,683
Reaction score
56
Location
Romania.
Im looking for a code for TFS, to open hidden holes on the desert.
If someone have one, please share with me. Thanks in advance
 
Thank you Evil Hero, you too Agostino. I just came back home and was gonna post them too. I will also need for those holes in other caves but I suppouse I just have to change the ids
 
Here it is:

NOTE! this is just an edited version of the shovel!

Code:
local holes = {468, 481, 483, 231, 482}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isInArray(holes, itemEx.itemid) == TRUE then
		doTransformItem(itemEx.uid, itemEx.itemid + 1)
		doDecayItem(itemEx.uid)
	elseif itemEx.itemid == 231 then
		local rand = math.random(1, 100)
		if rand == 1 then
			doCreateItem(2159, 1, toPosition)
		elseif rand > 95 then
			doSummonCreature("Scarab", toPosition)
		end
		doSendMagicEffect(toPosition, CONST_ME_POFF)
	else
		return FALSE
	end
	return TRUE
end

just replace your old shovel.lua with this script and it will work fine ^^

yours Evil Hero,
 
How is it gonna know where the hole is supposed to be?
And the hole also has to transform back to sand after some time.

Edit: every time i use the shovel on the sand it will create a tile of item 232, item id 231 is already an open hole.
Edit2: the hole is item id 489 this one transforms to sand by default after 30 seconds.
 
Last edited:
well the shovel is now just bassicly able to open the holes which you gave me the id :p
i thought you just wanted it that you can open the hole with the shovel now

i guess I'll look how to make that possible with the decay thing ^^

yours Evil Hero,
 
i was looking around on different ot forums and i found a script for it, it was for evo but i fixed it a bit and now it works for TFS.
I used action id 1593 but you can change it to whatever you want.

Edit: check second page for working script.
 
Last edited:
i was looking around on different ot forums and i found a script for it, it was for evo but i fixed it a bit and now it works for TFS.
I used action id 1593 but you can change it to whatever you want.

PHP:
local holes = {468, 481, 483}
function onUse(cid, item, fromPosition, itemEx, toPosition)
sandrand = math.random(1, 10)
    if itemEx.itemid == 0 then
    return 0
    end
    if (itemEx.actionid >= 1593 and sandrand == 5) then
    if itemEx.itemid == 231 then
        doCreateItem(489, 1, toPosition)
        doSendMagicEffect(toPositions,2)
        doDecayItem(itemEx.uid)
    else
        doSendMagicEffect(toPosition,2)
    end
    return 1
    end

    if isInArray(holes, itemEx.itemid) == TRUE then
        doTransformItem(itemEx.uid, itemEx.itemid + 1)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 231 then
        rand = math.random(1, 100)
    if rand > 95 then
        doSummonCreature("Scarab", toPosition)
    elseif rand == 1 then
        doCreateItem(2159, 1, toPosition)
    else
        doSendMagicEffect(toPosition,2)
    end
    else
    return 0
    end
    return 1
end
But the problem with the holes not wanting to change back to sand is still there.
Doesn't work for me on tfs..
 
Just tabbing it:
PHP:
local holes = {468, 481, 483}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	sandrand = math.random(1, 10)
	if itemEx.itemid == 0 then
		return 0
	end
	if (itemEx.actionid >= 1593 and sandrand == 5) then
		if itemEx.itemid == 231 then
			doCreateItem(489, 1, toPosition)
			doSendMagicEffect(toPositions,2)
			doDecayItem(itemEx.uid)
		else
			doSendMagicEffect(toPosition,2)
		end
		return 1
	end

	if isInArray(holes, itemEx.itemid) == TRUE then
		doTransformItem(itemEx.uid, itemEx.itemid+1)
		doDecayItem(itemEx.uid)
	elseif itemEx.itemid == 231 then
		rand = math.random(1, 100)
		if rand > 95 then
			doSummonCreature("Scarab", toPosition)
		elseif rand == 1 then
			doCreateItem(2159, 1, toPosition)
		else
			doSendMagicEffect(toPosition,2)
		end
	else
		return 0
	end
	return 1
end
 
Last edited:
I finally got it to work thanks to 4220niller for the doDecayItemTo function and AGS for part of the script.
It will give you a 1 out of 10 chance of opening the hole similar to rl tibia, then changes it back to the desert tile after the set amount of time which you can change in the script.

Put this in your data\actions\lib\actions.lua
PHP:
function decayItem(params)
    local item = getThingfromPos(params.itempos)
    local toitem = params.toitem
    if toitem == nil or toitem == 0 then
        doRemoveItem(item.uid,1)
    else
        doTransformItem(item.uid,toitem)
    end
end

function doDecayItemTo(itempos, toitem, timer)
    params = {itempos=itempos, toitem=toitem}
    addEvent(decayItem, timer*1000, params)
end
And replace your current shovel.lua with:
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local holes = {468, 481, 483}
aID = 1593 --Action Id the ground tile must have to turn into a hole.
ticks = 30 --How many seconds the hole will last before turning into a normal tile again
topos = {x=toPosition.x, y=toPosition.y, z=toPosition.z}
sandrand = math.random(1, 10)
    if itemEx.itemid == 0 then
        return 0
    end
if (itemEx.actionid == aID and sandrand == 5) then
    if itemEx.itemid == 231 then
        doTransformItem(itemEx.uid,482)
        doSendMagicEffect(toPosition,2)
        doDecayItemTo(toPosition, itemEx.itemid, ticks)
        else
            doSendMagicEffect(toPosition,2)
        end
        return 1
    end

    if isInArray(holes, itemEx.itemid) == TRUE then
        doTransformItem(itemEx.uid, itemEx.itemid+1)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 231 then
        rand = math.random(1, 100)
        if rand > 95 then
            doSummonCreature("Scarab", toPosition)
        elseif rand == 1 then
            doCreateItem(2159, 1, toPosition)
        else
            doSendMagicEffect(toPosition,2)
        end
    else
        return 0
    end
    return 1
end
Make sure you set the action id on the sand tile in your map editor.
Tested this on my server and it works perfect.
 
Back
Top