• 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 1.1 mining script

7804364

Member
Joined
Mar 6, 2010
Messages
457
Reaction score
10
Ok so when i use my pick action,
on the object it says
"You cannot use this object."


Code:
local configs = {
sign = {
     {level = {8,12}, quant = {1,2}, percent = 10},
     {level = {13,19}, quant = {1,2}, percent = 12},
     {level = {20,25}, quant = {1,2}, percent = 14},
     {level = {26,33}, quant = {1,2}, percent = 16},
     {level = {34,40}, quant = {1,2}, percent = 18},
     {level = {41,50}, quant = {1,2}, percent = 20},
     {level = {51,50}, quant = {1,3}, percent = 22},
     {level = {61,75}, quant = {1,3}, percent = 24},
     {level = {76,99}, quant = {1,4}, percent = 26},
     {level = {100}, quant = {1,4}, percent = 28}
},
stones = {11535, 11534, 11536, 11537},
gold = {
    {8306, 'all'},
    {2160, 'all'},
    {5880, 'all'},
    {2157, 'all'},
    {2149, 'all'},
    {2146, 'all'},
    {2258, 'all'},
    {2259, 'all'},
    {2267, 'all'},
    {2365, 'all'}
},
    stone_delay = 600,
    MaxLevel = 175,
    breakChance = 5

}
--END Configs--
function onUse(cid, item, fromPosition, itemEx, toPosition, onUse)
local STORAGE_SKILL_LEVEL = 20000
local STORAGE_SKILL_TRY = 20001 
local skillLevel = getPlayerStorageValue(cid,STORAGE_SKILL_LEVEL)
local skillTry = getPlayerStorageValue(cid,STORAGE_SKILL_TRY)
local objeto2 = getThingFromPos(toPosition)
local player = getCreaturePosition(cid)

  if skillLevel == -1 then
   setPlayerStorageValue(cid,STORAGE_SKILL_LEVEL,1)
  end
  for Q = 1, #configs.sign do
    if configs.sign[Q].level[2] == nil then
    configs.sign[Q].level[2] = configs.sign[Q].level[1]
    end
     if skillLevel >= configs.sign[Q].level[1] and skillLevel <= configs.sign[Q].level[2] then
     quant = math.random(configs.sign[Q].quant[1],configs.sign[Q].quant[2])
     percent = configs.sign[Q].percent
      break
     end
  end
for i = 1, #configs.stones do
  if objeto2.itemid == configs.stones[i] then

    if math.random(1,100) <= configs.breakChance then
          doPlayerSendCancel(cid,"Your pick has broke")
         doSendMagicEffect(toPosition, 3)
      doRemoveItem(item.uid,1)
          doSendAnimatedText(getCreaturePosition(cid), 'Broke!', 180, cid)
          return true
    else

    if math.random(1,100) <= percent then
    possible_gold = {{},{}}
        for h = 1, #configs.gold do
          if configs.gold[h][2] == objeto2.itemid then
           possible_gold[1][#possible_gold[1]+1] = configs.gold[h][1]
          else
            if configs.gold[h][2] == 'all' then
             possible_gold[2][#possible_gold[2]+1] = configs.gold[h][1]
            end
          end
        end
      if possible_gold[1][1] == nil and possible_gold[2][1] == nil then   
       doPlayerSendTextMessage(cid,22,"This stone can not be mined.")
      elseif possible_gold[1][1] ~= nil then   
        doPlayerAddItem(cid,possible_gold[1][math.random(1,#possible_gold[1])],quant)
      elseif possible_gold[1][1] == nil and possible_gold[2][1] ~= nil then   
        doPlayerAddItem(cid,possible_gold[2][math.random(1,#possible_gold[2])],quant)   
      end
     if possible_gold[1][1] ~= nil or possible_gold[2][1] ~= nil then
      if skillTry >= 0 then
        setPlayerStorageValue(cid,STORAGE_SKILL_TRY,skillTry + 1)
      else
       setPlayerStorageValue(cid,STORAGE_SKILL_TRY,1)
      end
      doSendMagicEffect(getCreaturePosition(cid), 12)
      doPlayerSendTextMessage(cid,22,"Tack!")
      doSendAnimatedText(getCreaturePosition(cid), ''..quant..'', 60, cid)
      doSendAnimatedText(getCreaturePosition(cid), 'Tack!', 35, cid)
      doItemSetAttribute(objeto2.uid, "name", "remains of gold ore")
      doSendMagicEffect(toPosition, 3)
      addEvent(dostoneReturn,configs.stone_delay * 1000,toPosition,objeto2.itemid)
      doTransformItem(objeto2.uid, 11539)
      break
     end
    else
     doPlayerSendCancel(cid,"You got nothing")
     doSendMagicEffect(toPosition, 3)
     doItemSetAttribute(objeto2.uid, "name", "remains of gold ore")
     doSendAnimatedText(getCreaturePosition(cid), 'Miss!', 180, cid)
     addEvent(dostoneReturn,configs.stone_delay * 1000,toPosition,objeto2.itemid)
     doTransformItem(objeto2.uid, 11538)
     break
    end
    end
  else
   doPlayerSendCancel(cid,"You can only mine gold ores")
  end
end
  if skillTry >= ((skillLevel+1)*3)  then
    if skillLevel == configs.MaxLevel then
     doPlayerSendTextMessage(cid, 22, "Max level reached in mining.")
     setPlayerStorageValue(cid,STORAGE_SKILL_TRY,0)
    else
     setPlayerStorageValue(cid,STORAGE_SKILL_LEVEL,skillLevel + 1)
     setPlayerStorageValue(cid,STORAGE_SKILL_TRY,0)
     doPlayerSendTextMessage(cid, 22, "You advanced from level ".. skillLevel .." to level ".. skillLevel + 1 .." in mining skill.")
     doSendMagicEffect(getCreaturePosition(cid),14)
     doSendAnimatedText(getCreaturePosition(cid), 'LEVEL UP!', 18, cid)
    end
  end
end

function dostoneReturn(itemposition,oldid)
local pos = getThingfromPos(itemposition)
  doTransformItem(pos.uid,oldid)
  doSetItemText(pos.uid, getItemNameById(oldid))
  doSendMagicEffect(itemposition,math.random(28,30))
end
 
Back
Top