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

(TFS 0.4) Simple mining system

Heyron

Active Member
Joined
Mar 23, 2017
Messages
103
Solutions
1
Reaction score
42
Location
Brazil
I need some help to set up this mining system.

1 - If mine something, remove the item that was broken (stones, trees...)
2 - Make the broken item reappear after 5 minutes.

Lua:
local SKINS = {

-- Normal Pick
    [5908] = {
   
        -- Stones
        [4259] = {25, 5876},
        [4262] = {25, 5876},
        [4256] = {25, 5876},
        [4256] = {25, 5876},
        [4256] = {25, 5876},

        -- Blue Cave Crystal
        [3104] = {25, 5877},
        [2844] = {25, 5877},

        -- Green Cave Crystal
        [2881] = {25, 5948},
        [2881] = {25, 5948},

        -- Red Cave Crystal
        [2931] = {25, 5893},
        [2931] = {25, 5893},

        -- Light Blue Cave Crystal
        [3031] = {25, 5925}
        [3031] = {25, 5925}
    },
   
-- Axe
    [5942] = {
   
        -- Trees
        [2956] = {25, 5905},
        [2956] = {25, 5905},
        [2956] = {25, 5905},
        [2956] = {25, 5905},
        [2956] = {25, 5905},

        -- Bushes
        [2916] = {25, 5906}
        [2916] = {25, 5906}
        [2916] = {25, 5906}
        [2916] = {25, 5906}
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local skin = SKINS[item.itemid][itemEx.itemid]
    if(skin == nil) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        return true
    end

    local random, effect = math.random(1, 100), CONST_ME_MAGIC_GREEN
    if(random <= skin[1]) then
        doPlayerAddItem(cid, skin[2], 1)
    elseif(skin[3] and random >= skin[3]) then
        doPlayerAddItem(cid, skin[4], 1)
    else
        effect = CONST_ME_POFF
    end

    doSendMagicEffect(toPosition, effect)
    doTransformItem(itemEx.uid, itemEx.itemid + 1)
    return true
end
 
Last edited:
change
Lua:
doTransformItem(itemEx.uid, itemEx.itemid + 1)
to
Lua:
addEvent(doCreateItem, (5 * 60 * 1000), itemEx.itemid, 1, toPosition)
doRemoveItem(itemEx.uid)
 
Last edited:
Solution
change
Lua:
doTransformItem(itemEx.uid, itemEx.itemid + 1)
to
Lua:
addEvent(doCreateItem, (5 * 60 * 1000), itemEx.itemid, 1, toPosition)
doRemoveItem(cid, itemEx.uid)

Screenshot_1.png

Did I do it right?

Lua:
local SKINS = {

-- Normal Pick
    [4874] = {
 
        -- Stones
        [9419] = {25, 8306},
        [9420] = {25, 8306},
        [9421] = {25, 8306},
        [9422] = {25, 8306},

        -- Blue Cave Crystal
        [3104] = {25, 5877},
        [2844] = {25, 5877},

        -- Green Cave Crystal
        [2881] = {25, 5948},
        [2881] = {25, 5948},

        -- Red Cave Crystal
        [2931] = {25, 5893},
        [2931] = {25, 5893},

        -- Light Blue Cave Crystal
        [3031] = {25, 5925},
        [3031] = {25, 5925},
    },
 
-- Axe
    [2386] = {
 
        -- Trees
        [2956] = {25, 5905},
        [2956] = {25, 5905},
        [2956] = {25, 5905},
        [2956] = {25, 5905},
        [2956] = {25, 5905},

        -- Bushes
        [2916] = {25, 5906},
        [2916] = {25, 5906},
        [2916] = {25, 5906},
        [2916] = {25, 5906},
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local skin = SKINS[item.itemid][itemEx.itemid]
    if(skin == nil) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        return true
    end

    local random, effect = math.random(1, 100), CONST_ME_MAGIC_GREEN
    if(random <= skin[1]) then
        doPlayerAddItem(cid, skin[2], 1)
    elseif(skin[3] and random >= skin[3]) then
        doPlayerAddItem(cid, skin[4], 1)
    else
        effect = CONST_ME_POFF
    end

    doSendMagicEffect(toPosition, effect)
    addEvent(doCreateItem, (1 * 60 * 1000), itemEx.itemid, 1, toPosition)
    doRemoveItem(cid, itemEx.uid)
    return true
end
 
View attachment 54644

Did I do it right?

Lua:
local SKINS = {

-- Normal Pick
    [4874] = {
 
        -- Stones
        [9419] = {25, 8306},
        [9420] = {25, 8306},
        [9421] = {25, 8306},
        [9422] = {25, 8306},

        -- Blue Cave Crystal
        [3104] = {25, 5877},
        [2844] = {25, 5877},

        -- Green Cave Crystal
        [2881] = {25, 5948},
        [2881] = {25, 5948},

        -- Red Cave Crystal
        [2931] = {25, 5893},
        [2931] = {25, 5893},

        -- Light Blue Cave Crystal
        [3031] = {25, 5925},
        [3031] = {25, 5925},
    },
 
-- Axe
    [2386] = {
 
        -- Trees
        [2956] = {25, 5905},
        [2956] = {25, 5905},
        [2956] = {25, 5905},
        [2956] = {25, 5905},
        [2956] = {25, 5905},

        -- Bushes
        [2916] = {25, 5906},
        [2916] = {25, 5906},
        [2916] = {25, 5906},
        [2916] = {25, 5906},
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local skin = SKINS[item.itemid][itemEx.itemid]
    if(skin == nil) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        return true
    end

    local random, effect = math.random(1, 100), CONST_ME_MAGIC_GREEN
    if(random <= skin[1]) then
        doPlayerAddItem(cid, skin[2], 1)
    elseif(skin[3] and random >= skin[3]) then
        doPlayerAddItem(cid, skin[4], 1)
    else
        effect = CONST_ME_POFF
    end

    doSendMagicEffect(toPosition, effect)
    addEvent(doCreateItem, (1 * 60 * 1000), itemEx.itemid, 1, toPosition)
    doRemoveItem(cid, itemEx.uid)
    return true
end
doRemoveItem(itemEx.uid)
 
Back
Top