Shinmaru
エロルアー Scripter!
First: This is not my script so credits to the maker, I only added a few things and made it better(and messier
)now let's begin:
Copy this and name it mining.lua and place it in the folder: data/actions/scripts
or use this one by Cykotitan (TFS 0.3.5)
or this one (TFS 0.3.6)
then copy this to actions.xml :
and your done.
I tested this on TFS 0.3.5 Crying Damson and it works perfectly.
Edit:I tested the scripts and they work.

Copy this and name it mining.lua and place it in the folder: data/actions/scripts
Code:
-- Mining V2.7
-- Please understand this is more of a bug fix release
-- Coded by Roman, some credits to twiz for giving an example of his V1.0
-- Edited by 375311 Changes: Made it more balanced on the random, now money and precious rocks has random count
local g = math.random(1,100) -- amount of gold
local dmg = math.random(1,100) -- damage
s = {1285,1356,1357,1358,1359,3608} -- stone id
a = math.random(1,10000) -- general amount
function onUse(cid, item, frompos, item2, topos)
if a <= 1000 then
a1 = 1
elseif a <= 2000 then
a1 = 2
elseif a <= 3000 then
a1 = 3
elseif a <= 4000 then
a1 = 4
elseif a <= 5000 then
a1 = 5
elseif a <= 6000 then
a1 = 6
elseif a <= 7000 then
a1 = 7
elseif a <= 8000 then
a1 = 8
elseif a <= 9000 then
a1 = 9
elseif a <= 10000 then
a1 = 10
end
Level = getPlayerLevel(cid)
ClubSkill = getPlayerSkill(cid,1)
if isInArray(s, item2.itemid) == true and
Level >= 20 -- set the level requirement to be able to mine
and
ClubSkill >= 15 -- set the club skill requirement to be able to mine
then
rand = math.random(1,2000)
if rand <= 100 then
doPlayerSendTextMessage(cid,22,"Oh no, you missed and picked a hole in the ground and a Rat came out of it!")
doSummonCreature("Rat", topos)
elseif rand <= 200 then
doPlayerSendTextMessage(cid,22,"You found ".. a1 .." golden nugget.")
doPlayerAddItem(cid,2157,a1)
doTransformItem(item2.uid, 1336)
elseif rand <= 300 then
doPlayerSendTextMessage(cid,22,"You found ".. a1 .." diamond.")
doPlayerAddItem(cid,2145,a1)
doTransformItem(item2.uid, 1336)
elseif rand <= 400 then
doPlayerSendTextMessage(cid,22,"You found an iron ore.")
doPlayerAddItem(cid,2225,1)
doTransformItem(item2.uid, 1336)
elseif rand <= 500 and Level >= 20 then
doPlayerSendTextMessage(cid,22,"You found ".. g .." gold coin.")
doPlayerAddItem(cid,2148,g)
doTransformItem(item2.uid, 1336)
elseif rand <= 600 then
doPlayerSendTextMessage(cid,22,"You found ".. a1 .." small sapphire.")
doPlayerAddItem(cid,2146,a1)
doTransformItem(item2.uid, 1336)
elseif rand <= 700 then
doPlayerSendTextMessage(cid,22,"You found ".. a1 .." small emerald.")
doPlayerAddItem(cid,2149,a1)
doTransformItem(item2.uid, 1336)
elseif rand <= 800 then
doPlayerSendTextMessage(cid,22,"You found ".. a1 .." small amethyst.")
doPlayerAddItem(cid,2150,a1)
doTransformItem(item2.uid, 1336)
elseif rand <= 900 then
doPlayerSendTextMessage(cid,22,"You found an iron ore.")
doPlayerAddItem(cid,2225,1)
doTransformItem(item2.uid, 1336)
elseif rand <= 1000 then
doCreatureAddHealth(cid,-dmg)
doPlayerSendTextMessage(cid,22,"You lost ".. dmg .." hitpoints due to exhaustion of mining.")
doTransformItem(item2.uid, 1336)
elseif rand <= 1100 then
doPlayerSendTextMessage(cid,22,"You found ".. a1 .." ruby.")
doPlayerAddItem(cid,2147,a1)
doTransformItem(item2.uid, 1336)
elseif rand <= 1200 then
doPlayerSendTextMessage(cid,22,"You found ".. a1 .." white pearl.")
doPlayerAddItem(cid,2143,a1)
doTransformItem(item2.uid, 1336)
elseif rand <= 1300 then
doPlayerSendTextMessage(cid,22,"You found ".. a1 .." black pearl.")
doPlayerAddItem(cid,2144,a1)
doTransformItem(item2.uid, 1336)
elseif rand <= 1400 then
doPlayerSendTextMessage(cid,22,"An angry dwarf has come out of the rock piles.")
doSummonCreature("Dwarf", topos)
doTransformItem(item2.uid, 1336)
elseif rand <= 1500 then
doPlayerSendTextMessage(cid,22,"A badger got unstuck and it looks angry!")
doSummonCreature("Badger", topos)
doTransformItem(item2.uid, 1336)
elseif rand <= 1600 then
doPlayerSendTextMessage(cid,22,"A rotworm came from a hole you made on the ground!")
doSummonCreature("Rotworm", topos)
elseif rand <= 1700 then
doPlayerSendTextMessage(cid,22,"You suffered ".. dmg .." hitpoints due to the Earthquake!")
doCreatureAddHealth(cid,-dmg)
doTransformItem(item2.uid, 1336)
elseif rand <= 1800 then
doPlayerSendTextMessage(cid,22,"A weak troll has appeared from the pile of rocks!")
doSummonCreature("Troll", topos)
doTransformItem(item2.uid, 1336)
elseif rand <= 1900 then
doPlayerSendTextMessage(cid,22,"Woah! a skeleton just appeared from the pile of rocks!")
doSummonCreature("Skeleton", topos)
doTransformItem(item2.uid, 1336)
elseif rand <= 2000 then
doRemoveItem(item.uid,1)
doSendMagicEffect(topos,2)
doPlayerSendTextMessage(cid,22,"Your pick has been heavily damaged and broke...")
doTransformItem(item2.uid, 1336)
end
doSendMagicEffect(topos,3)
doPlayerAddSkillTry(cid,1,100)
doPlayerSay(cid,"Hmm, what is this...?",1)
else
doPlayerSendCancel(cid,"You lack the level and/or the skill to break this rock or the rock is unbreakable.")
end
return 1
end
or use this one by Cykotitan (TFS 0.3.5)
Code:
--By:Cykotitan Improvised Version--
local config = {
stones = {1285, 1356, 1357, 1358, 1359, 3608},
level = 20,
skill = SKILL_CLUB,
skillReq = 15,
effect = CONST_ME_BLOCKHIT,
addTries = 100,
debris = 1336,
msgType = MESSAGE_EVENT_ADVANCE
}
local t = {
[{1, 100}] = {msg = "Oh no, you missed and picked a hole in the ground and a rat came out of it!", summon = "Rat"},
[{101, 200}] = {msg = "You found %A %N.", item = 2157, amountmax = 10},
[{201, 300}] = {msg = "You found %A %N.", item = 2145, amountmax = 10},
[{301, 400}] = {msg = "You found %A %N.", item = 2225},
[{401, 500}] = {msg = "You found %A %N.", item = 2148, amountmax = 100},
[{501, 600}] = {msg = "You found %A %N.", item = 2146, amountmax = 10},
[{601, 700}] = {msg = "You found %A %N.", item = 2149, amountmax = 10},
[{701, 800}] = {msg = "You found %A %N.", item = 2150, amountmax = 10},
[{801, 900}] = {msg = "You found %A %N.", item = 5880},
[{901, 1000}] = {msg = "You lost %D hitpoints due to exhaustion of mining.", damage = {1, 100}},
[{1001, 1100}] = {msg = "You found %A %N.", item = 2147, amountmax = 10},
[{1101, 1200}] = {msg = "You found %A %N.", item = 2143, amountmax = 10},
[{1201, 1300}] = {msg = "You found %A %N.", item = 2144, amountmax = 10},
[{1301, 1400}] = {msg = "An angry dwarf came out of the rock piles!", summon = "Dwarf"},
[{1401, 1500}] = {msg = "A badger got unstuck and it looks angry!", summon = "Badger"},
[{1501, 1600}] = {msg = "A rotworm came from a hole you made on the ground!", summon = "Rotworm"},
[{1601, 1700}] = {msg = "You suffered %D hitpoints due to an earthquake!", damage = {1, 100}},
[{1701, 1800}] = {msg = "A weak troll has appeared from the pile of rocks!", summon = "Troll"},
[{1801, 1900}] = {msg = "Woah! A skeleton just appeared from the pile of rocks!", summon = "Skeleton"},
[{1901, 2000}] = {msg = "Your pick has been heavily damaged and it broke...", destroy = true}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if isInArray(config.stones, itemEx.itemid) and config.level <= getPlayerLevel(cid) and config.skillReq <= getPlayerSkill(cid, config.skill) then
local v, amount, damage = math.random(2000), 1, nil
for i, k in pairs(t) do
if v >= i[1] and v <= i[2] then
if k.destroy then
doRemoveItem(item.uid)
end
if k.summon then
doCreateMonster(k.summon, toPosition)
end
if k.damage then
damage = math.random(k.damage[1], k.damage[2])
doCreatureAddHealth(cid, - damage)
doSendMagicEffect(getThingPos(cid), CONST_ME_DRAWBLOOD)
doSendAnimatedText(getThingPos(cid), damage, TEXTCOLOR_RED)
end
if k.item then
if k.amountmax then
amount = math.random(k.amountmax)
end
doPlayerAddItem(cid, k.item, amount)
end
if k.msg then
local msg = k.msg
if msg:find("%%") then
if msg:find("%%A") and k.item then
msg = msg:gsub("%%A", amount > 1 and amount or getItemDescriptionsById(k.item).article)
end
if msg:find("%%N") and k.item then
msg = msg:gsub("%%N", amount > 1 and getItemDescriptionsById(k.item).plural or getItemNameById(k.item))
end
if msg:find("%%D") and damage then
msg = msg:gsub("%%D", damage)
end
end
doPlayerSendTextMessage(cid, config.msgType, msg)
end
doTransformItem(itemEx.uid, config.debris)
doSendMagicEffect(toPosition, k.destroy and CONST_ME_HITAREA or config.effect)
return doPlayerAddSkillTry(cid, config.skill, config.addTries)
end
end
end
return doPlayerSendCancel(cid, "You either aren't experienced or skilled enough or this isn't a breakable rock.")
end
or this one (TFS 0.3.6)
Code:
local config = {
stones = {1285, 1356, 1357, 1358, 1359, 3608},
level = 20,
skill = SKILL_CLUB,
skillReq = 15,
effect = CONST_ME_BLOCKHIT,
addTries = 100,
debris = 1336,
msgType = MESSAGE_EVENT_ADVANCE
}
local t = {
[{1, 100}] = {msg = "Oh no, you missed and picked a hole in the ground and a rat came out of it!", summon = "Rat"},
[{101, 200}] = {msg = "You found %A %N.", item = 2157, amountmax = 10},
[{201, 300}] = {msg = "You found %A %N.", item = 2145, amountmax = 10},
[{301, 400}] = {msg = "You found %A %N.", item = 2225},
[{401, 500}] = {msg = "You found %A %N.", item = 2148, amountmax = 100},
[{501, 600}] = {msg = "You found %A %N.", item = 2146, amountmax = 10},
[{601, 700}] = {msg = "You found %A %N.", item = 2149, amountmax = 10},
[{701, 800}] = {msg = "You found %A %N.", item = 2150, amountmax = 10},
[{801, 900}] = {msg = "You found %A %N.", item = 5880},
[{901, 1000}] = {msg = "You lost %D hitpoints due to exhaustion of mining.", damage = {1, 100}},
[{1001, 1100}] = {msg = "You found %A %N.", item = 2147, amountmax = 10},
[{1101, 1200}] = {msg = "You found %A %N.", item = 2143, amountmax = 10},
[{1201, 1300}] = {msg = "You found %A %N.", item = 2144, amountmax = 10},
[{1301, 1400}] = {msg = "An angry dwarf came out of the rock piles!", summon = "Dwarf"},
[{1401, 1500}] = {msg = "A badger got unstuck and it looks angry!", summon = "Badger"},
[{1501, 1600}] = {msg = "A rotworm came from a hole you made on the ground!", summon = "Rotworm"},
[{1601, 1700}] = {msg = "You suffered %D hitpoints due to an earthquake!", damage = {1, 100}},
[{1701, 1800}] = {msg = "A weak troll has appeared from the pile of rocks!", summon = "Troll"},
[{1801, 1900}] = {msg = "Woah! A skeleton just appeared from the pile of rocks!", summon = "Skeleton"},
[{1901, 2000}] = {msg = "Your pick has been heavily damaged and it broke...", destroy = true}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if isInArray(config.stones, itemEx.itemid) and config.level <= getPlayerLevel(cid) and config.skillReq <= getPlayerSkill(cid, config.skill) then
local v, amount, damage = math.random(2000), 1, nil
for i, k in pairs(t) do
if v >= i[1] and v <= i[2] then
if k.destroy then
doRemoveItem(item.uid)
end
if k.summon then
doCreateMonster(k.summon, toPosition)
end
if k.damage then
damage = math.random(k.damage[1], k.damage[2])
doCreatureAddHealth(cid, - damage, CONST_ME_DRAWBLOOD, TEXTCOLOR_RED)
end
if k.item then
if k.amountmax then
amount = math.random(k.amountmax)
end
doPlayerAddItem(cid, k.item, amount)
end
if k.msg then
local msg = k.msg
if msg:find("%%") then
if msg:find("%%A") and k.item then
msg = msg:gsub("%%A", amount > 1 and amount or getItemDescriptionsById(k.item).article)
end
if msg:find("%%N") and k.item then
msg = msg:gsub("%%N", amount > 1 and getItemDescriptionsById(k.item).plural or getItemNameById(k.item))
end
if msg:find("%%D") and damage then
msg = msg:gsub("%%D", damage)
end
end
doPlayerSendTextMessage(cid, config.msgType, msg)
end
doTransformItem(itemEx.uid, config.debris)
doSendMagicEffect(toPosition, k.destroy and CONST_ME_HITAREA or config.effect)
return doPlayerAddSkillTry(cid, config.skill, config.addTries)
end
end
end
return doPlayerSendCancel(cid, "You either aren't experienced or skilled enough or this isn't a breakable rock.")
end
then copy this to actions.xml :
Code:
<action itemid="2553" event="script" value="mining.lua"/>
and your done.
I tested this on TFS 0.3.5 Crying Damson and it works perfectly.
Edit:I tested the scripts and they work.
Last edited: