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

Help me with mining system

Gothrim

New Member
Joined
Jan 23, 2009
Messages
20
Reaction score
0
Im trying to make mining system. It's working partially, but i can't finish it.
It's based on "Weedcuting System".

Code:
<config name="mining Lib"><![CDATA[
mining = {}

mining.ironreward = 5880
mining.coalreward = 10609
mining.exhaust = 2 * 1000
mining.ironveins = {8740, 8741, 8742, 8743}
mining.coalveins = {8748, 8749, 8750, 8751}
mining.try = {"uderza kilofem w skale z lewej", "uderza kilofem w skale z prawej", "bierze spory zamach kilofem i uderza", "uderza kilofem w skale", "trzymajac trzonek kilofu w dloniach usiluje rozlupac skale", "uderza kilofem w skale z nad glowy", "uderza kilofem w skale i wokol rozsypuja sie iskry",}
mining.maxLevel = 100
mining.stor = {878, 877}
mining.showLevel = true


function mining.getPlayerSkill(cid)
        return getPlayerStorageValue(cid, mining.stor[1])
end

function mining.addSkillTry(cid)
        if(getPlayerStorageValue(cid, mining.stor[1]) >= mining.maxLevel) then
                return true
        end
        local formula = getPlayerStorageValue(cid, mining.stor[1]) / 10
        if(math.random(1, formula) == 1) then
                if(getPlayerStorageValue(cid, mining.stor[2]) >= (getPlayerStorageValue(cid, 876) + (getPlayerStorageValue(cid, 876) * (getPlayerStorageValue(cid, 876) / 2))) * (getPlayerStorageValue(cid, 876) / 5.25)) then
                        setPlayerStorageValue(cid, mining.stor[2], 0)
                        setPlayerStorageValue(cid, mining.stor[1], getPlayerStorageValue(cid, mining.stor[1])+1)
                        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You advanced in Mining. "..(mining.showLevel == true and "["..getPlayerStorageValue(cid, mining.stor[1]).."]" or "").."")
                else
                        setPlayerStorageValue(cid, mining.stor[2], getPlayerStorageValue(cid, mining.stor[2])+1)
                end
        end
return true
end
]]></config>

<action itemid="2553" event="script"><![CDATA[
        domodlib("mining Lib")

function onUse(cid, item, fromPosition, itemEx, toPosition)

                if(isInArray(mining.ironveins, itemEx.itemid) == false) then
                        return false
                end

local dlonie = {getPlayerSlotItem(cid, 6).itemid, getPlayerSlotItem(cid, 5).itemid}
                if(isInArray(dlonie, item.itemid) == false) then
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Trzymaj " .. getItemNameById(item.itemid) .. " w dloni!")
                        return false
                end
                   

                if(getPlayerStorageValue(cid, 800) <= -1) then
                mining.addSkillTry(cid)
       	        local teksty = (math.random(1, 7))
                doCreatureSay(cid, getCreatureName(cid) .. ' ' .. mining.try[teksty] .. '.', TALKTYPE_MONSTER)
                doSendMagicEffect(toPosition, 9)
                setPlayerStorageValue(cid, 800, 1)
                local params = {cid = cid}
                addEvent(innego, mining.exhaust, params)
                if(math.random(mining.getPlayerSkill(cid), mining.maxLevel) >= mining.maxLevel) then
                        local itemid = itemEx.itemid
                        doPlayerAddItem(cid, mining.ironreward, (math.random(0, 2)), true)
                        doRemoveItem(itemEx.uid, 1)
                        doCreatureSay(cid, 'Skala ulegla sile jego miesni odslaniajac cenny kruszec', TALKTYPE_MONSTER)
                        doCreateItem(1336, 1, toPosition)
                        addEvent(function()
                                doRemoveItem(getThingFromPos(toPosition).uid)
                                pien = doCreateItem(1336, 1, toPosition)
                                doSendMagicEffect(toPosition, 44)
                                addEvent(function()
                                        doSendMagicEffect(toPosition, 44)
                                        doRemoveItem(getThingFromPos(toPosition).uid)
                                        doCreateItem(itemid, 1, toPosition)
                                end, 1 * 5 * 1000, {itemid = itemid, toPosition = toPosition})
                        end, 1 * 5 * 1000, {itemid = itemid, toPosition = toPosition})
                end
                else
                doCreatureSay(cid, getCreatureName(cid) .. ' nieco sie pospieszyl i wykonal za slaby zamach.', TALKTYPE_MONSTER)
                return false
                end
        end


function innego(params)
  if isPlayer(params.cid) then
      setPlayerStorageValue(params.cid, 800, "-1")
  end
end

And what is wrong?
I want to make this script recognize itemid of itemex vein and give another reward for mining.ironveins and another reward for mining.coalveins. There shall be another formula for succes:
Code:
(math.random(mining.getPlayerSkill(cid), mining.maxLevel) >= mining.maxLevel)
for iron, and
Code:
(math.random(mining.getPlayerSkill(cid), mining.maxLevel) >= mining.maxLevel - 1)
for coal

I made it once, but with copying half of code with using IsInArray. This is wrong method - the code is bigger by half and it's not simple to add another veins and another rewards. If I will use this method and try to make 6 veins type, the code will be 6 times bigger!
I need an smart, clear and universal method for that :(

Thanks
 
Back
Top