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

Action [1.3] Simple Mining System

Marko999x

999x era
Premium User
Joined
Dec 14, 2017
Messages
2,815
Solutions
82
Reaction score
1,938
Location
Germany
This script has been created by me and some help from OTLand ( as far as I know mostly from Xikini )
its a simple mining system which allows you to mining items and theres a 10% chance that the stone breaks and spawns back after 5min

How to make the script work:
Your stones which should be used as mining must have actionID: 40041.

Lua:
    local stones = {5750, 5751, 5752, 5753, 5754}
<- In this part you must add your stone ids which should be spawned back after the stone got broken.

in config part you can add items which should be able to mining and you can change the chance of it aswell.
100 means = 100%
10 means = 10%

Lua:
local delay_timer = 5
<- means you can mining every 5sec.

Code:
Lua:
local rewards = {
    { item = 8298, count = 1, chance = 50 },
    { item = 8299, count = 1, chance = 50 },
    { item = 8301, count = 1, chance = 50 },
    { item = 8302, count = 1, chance = 50 },
    { item = 8303, count = 1, chance = 50 },
    { item = 8310, count = 1, chance = 50 },
    { item = 9971, count = 1, chance = 50 },
    { item = 5944, count = 1, chance = 100 }
}

local storage = 5000
local delay_timer = 5

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    
    local cur_time, cur_storage = os.time(), player:getStorageValue(storage)
 
    if cur_storage > cur_time then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can mining again in " .. os.date("!%Hh %Mm %Ss", cur_storage - cur_time) .. ".")
        return true
    end
    
    local function addbackstone()
    local stones = {5750, 5751, 5752, 5753, 5754}
    local stone = Game.createItem(stones[math.random(#stones)], 1, toPosition)
        stone:setActionId(40041)
    end
    
    if player:getLevel() < 10 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You dont have the required level of 10 to mining.")
        return true
    end
    
    if not target then
        return false
    end
    
    if not target:isItem() then
        return false
    end

    if target.actionid ~= 40041 then
    local pos = player:getPosition()
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You cannot use it here.')
        return false
    end
    
    if target.actionid == 40041 then
    local ran = math.random(100)
        if ran <= 10 then
            toPosition:sendMagicEffect(3)
            target:remove()
            addEvent(addbackstone, 120000)
            return true
        end
    end
 
    local text = "You have found "
    for i = 1, #rewards do
        local rand = math.random(1000)
        if rand <= rewards[i].chance then
            player:addItem(rewards[i].item, rewards[i].count)
            if text ~= "You have found " then
                text = text .. ", "
            end
            text = text .. rewards[i].count .. " " .. ItemType(rewards[i].item):getName()
        end         
    end
    if text == "You have found " then
        text = text .. "nothing"
    end
    player:sendTextMessage(36, text .. ".")
    cur_time = cur_time + delay_timer
    player:setStorageValue(storage, cur_time)
    return true
end
 
Looks good, thanks for your contribution.

Only critique I can make is; if I understand this system correctly, you can obtain the same items from every stone, the stones only change their appearance on spawn. It would make more sense to have different rewards for each stone (creating tiers). Also, this system does not support mining levels/skill progression. If it did, I would recommend adding “minimum mining level to collect materials”.

Aside from that, I like the idea of a cool down!
 
Could be added for sure
but I do not feel like to do it to be honest, sorry
Maybe someone else will spend time on doing that
Looks good, thanks for your contribution.

Only critique I can make is; if I understand this system correctly, you can obtain the same items from every stone, the stones only change their appearance on spawn. It would make more sense to have different rewards for each stone (creating tiers). Also, this system does not support mining levels/skill progression. If it did, I would recommend adding “minimum mining level to collect materials”.

Aside from that, I like the idea of a cool down!
 
Could be added for sure
but I do not feel like to do it to be honest, sorry
Maybe someone else will spend time on doing that
Well regardless, I am sure your script be helpful/used by many players. Good contribution!
 
This script has been created by me and some help from OTLand ( as far as I know mostly from Xikini )
its a simple mining system which allows you to mining items and theres a 10% chance that the stone breaks and spawns back after 5min

How to make the script work:
Your stones which should be used as mining must have actionID: 40041.

Lua:
    local stones = {5750, 5751, 5752, 5753, 5754}
<- In this part you must add your stone ids which should be spawned back after the stone got broken.

in config part you can add items which should be able to mining and you can change the chance of it aswell.
100 means = 100%
10 means = 10%

Lua:
local delay_timer = 5
<- means you can mining every 5sec.

Code:
Lua:
local rewards = {
    { item = 8298, count = 1, chance = 50 },
    { item = 8299, count = 1, chance = 50 },
    { item = 8301, count = 1, chance = 50 },
    { item = 8302, count = 1, chance = 50 },
    { item = 8303, count = 1, chance = 50 },
    { item = 8310, count = 1, chance = 50 },
    { item = 9971, count = 1, chance = 50 },
    { item = 5944, count = 1, chance = 100 }
}

local storage = 5000
local delay_timer = 5

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
   
    local cur_time, cur_storage = os.time(), player:getStorageValue(storage)
 
    if cur_storage > cur_time then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can mining again in " .. os.date("!%Hh %Mm %Ss", cur_storage - cur_time) .. ".")
        return true
    end
   
    local function addbackstone()
    local stones = {5750, 5751, 5752, 5753, 5754}
    local stone = Game.createItem(stones[math.random(#stones)], 1, toPosition)
        stone:setActionId(40041)
    end
   
    if player:getLevel() < 10 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You dont have the required level of 10 to mining.")
        return true
    end
   
    if not target then
        return false
    end
   
    if not target:isItem() then
        return false
    end

    if target.actionid ~= 40041 then
    local pos = player:getPosition()
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You cannot use it here.')
        return false
    end
   
    if target.actionid == 40041 then
    local ran = math.random(100)
        if ran <= 10 then
            toPosition:sendMagicEffect(3)
            target:remove()
            addEvent(addbackstone, 120000)
            return true
        end
    end
 
    local text = "You have found "
    for i = 1, #rewards do
        local rand = math.random(1000)
        if rand <= rewards[i].chance then
            player:addItem(rewards[i].item, rewards[i].count)
            if text ~= "You have found " then
                text = text .. ", "
            end
            text = text .. rewards[i].count .. " " .. ItemType(rewards[i].item):getName()
        end        
    end
    if text == "You have found " then
        text = text .. "nothing"
    end
    player:sendTextMessage(36, text .. ".")
    cur_time = cur_time + delay_timer
    player:setStorageValue(storage, cur_time)
    return true
end
Hi bro, with which item is the stone broken?
 
@Levi999x

Can you help me? I have a problem with this part, and when I remove it from the action, it starts mining anywhere, more if I leave it active, or my client doesn't recognize the place of use.

Lua:
if target.actionid ~= 40041 then
    local pos = player:getPosition()
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You cannot use it here.')
        return false
    end

From what I see, my client that would be OTCClient 1.0 doesn't recognize the action " ~= "
 
@Levi999x

Can you help me? I have a problem with this part, and when I remove it from the action, it starts mining anywhere, more if I leave it active, or my client doesn't recognize the place of use.

Lua:
if target.actionid ~= 40041 then
    local pos = player:getPosition()
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You cannot use it here.')
        return false
    end

From what I see, my client that would be OTCClient 1.0 doesn't recognize the action " ~= "
what
 
Last edited:
How can make to just reward 1 item, no all of this

12:20 You have found 1 mother soil, 11 gold coin, 6 gold coin, 3 gold coin.
 
I must delete this sentence in pick.lua?
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
return onUsePick(player, item, fromPosition, target, toPosition, isHotkey)
end

or not?
When I delete pick work correctly?
 
Last edited:
I must delete this sentence in pick.lua?
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
return onUsePick(player, item, fromPosition, target, toPosition, isHotkey)
end

or not?
When I delete pick work correctly?

If u want to use default pick then u must remove the conntection to old script in action.xml
 
If u want to use default pick then u must remove the conntection to old script in action.xml
Thank you, but I still try make dwarven pickaxe to use this script :/ when I use pick everything work normaly thank you
 
whats not working?
I use TFS 1.4...
When I use PICK, the cursor changes to such that you choose the place where to use it. When I use DWARVEN PICKAXE, it immediately says that I can't use this and I don't see this cursor.

USE PICK (work):
use pick.png
USE DWARVEN PICKAXE (not work):
use dwarven pickaxe.png

There this thread:
 
Last edited:
I use TFS 1.4...
When I use PICK, the cursor changes to such that you choose the place where to use it. When I use DWARVEN PICKAXE, it immediately says that I can't use this and I don't see this cursor.

USE PICK (work):
View attachment 71229
USE DWARVEN PICKAXE (not work):
View attachment 71228

There this thread:

Edit your items.otb to make it work
 
Edit your items.otb to make it work
items.xml this?
or items.otb?
Can you help me with this? I don't even know what program to use and what to do for TFS 1.4.
I do this but still not working and when i load items.otb now I have this in red :/
Bez tytułu.png

EDIT:
I edit DAT to and work. Thanks for TIPS!
 
Last edited:
Back
Top