• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Mining V3 (inkl. Miningskill/Talkaction/Field Decay and more)

Virgel

New Member
Joined
Jun 14, 2007
Messages
150
Reaction score
2
This is Mining V3.2

Hope you like it! If yes plz give rep :) would be nice

- stable (without any bugs) tested on Forgotten Server
- works with Storage IDs

set 40001 to 0 or 1 via NPC if Player is able to mine (did he learn?)
set 40002 to 1 (or higher if you wish) via NPC if player learned mining, this is the miningskill (to start mining its important to set it higher the 0)
set 40003 to 0 via NPC (this counts the effective trys)
set 40004 to 0 via NPC (this will count how often Player used Pick) This is important if you wish to have the pick breaks after a while

- works with Item IDs (void)

4328 - mining ground
4329 - empty mining ground

You need to add this Item IDs to Item.xml and you have to put item 4328 (mining ground) everywhere you would like to have the Player can mine. It must be the stackpos on top! Remember that item id 4328 has no graphic so you cant see it on mapeditor! But you can test it when you click on ground where you have add 4328 with rightclick on it and check Properties.

- Talkactions added!

if Player says !mining he will see on screen "You Miningskill is ... now! For Skill ... you have ...% to go"

- if Miningskill goes up, player will see a message on screen "You advanced in mining! You miningskill is ... now."
- Stages for MiningSkill

Lets start!

mining.lua (Actions) includes Skill Stage 1 - 10 (you can add more)
Code:
--- Mining V3.2 all credits by Virgel
--- Player need to learn mining
--- Player has miningskill and trys
--- Pick will break after a while
--- field to mine can become empty (empty field will change to mining ground after x.minutes)
--- talkaction with command !mining

function onUse(cid, item, frompos, item2, topos)
playerCanMine = getPlayerStorageValue(cid,40001) --- player can mine yes 1 or no 0
playerSkillMine = getPlayerStorageValue(cid,40002) --- Miningskill from player
playerSkillTry = getPlayerStorageValue(cid,40003) --- this counts the efective trys
playerPickBroken = getPlayerStorageValue(cid,40004) --- counts how often you work with a pick
multipler = 1.5 --- when its higher peoples need to mine longer for next skillup, remember to change this in talkactions also!
brokePick = math.random(20,40) --- how many trys before a pick will break
needSkillTry = math.ceil(playerSkillMine * playerSkillMine * multipler - 1)

	if playerCanMine > 0 and item2.itemid == 4328 then

------- miningskills start here ------

		if playerSkillMine >= 1 and playerSkillMine<= 10 then
			if playerPickBroken < brokePick then
				newPlayerPickBroken = playerPickBroken+1
				setPlayerStorageValue(cid,40004, newPlayerPickBroken)
				rand = math.random(1,100)
				if rand <= 20 then
					newPlayerSkillTry = playerSkillTry + 1
					setPlayerStorageValue(cid,40003, newPlayerSkillTry)
					doPlayerAddItem(cid,5880,1)
					doPlayerSendTextMessage(cid,22,"You have found 1 iron ore!")
						if playerSkillTry >= needSkillTry then
							newPlayerSkillMine = playerSkillMine + 1
							setPlayerStorageValue(cid,40002,newPlayerSkillMine)
							setPlayerStorageValue(cid,40003,0)
							nowPlayerSkillMine = getPlayerStorageValue(cid,40002)
							doPlayerSendTextMessage(cid,22,"You advanced in mining! You Miningskill is "..nowPlayerSkillMine.." now!")
						end
				elseif rand >20 and rand <=50 then
					doPlayerSendTextMessage(cid,22,"Found nothing!")
				elseif rand >50 and rand <=73 then
					newPlayerSkillTry = playerSkillTry + 1
					setPlayerStorageValue(cid,40003, newPlayerSkillTry)
					doPlayerAddItem(cid,5880,2)
					doPlayerSendTextMessage(cid,22,"You have found 2 iron ore!")
						if playerSkillTry >= needSkillTry then
							newPlayerSkillMine = playerSkillMine + 1
							setPlayerStorageValue(cid,40002,newPlayerSkillMine)
							setPlayerStorageValue(cid,40003,0)
							nowPlayerSkillMine = getPlayerStorageValue(cid,40002)
							doPlayerSendTextMessage(cid,22,"You advanced in mining! You Miningskill is "..nowPlayerSkillMine.." now!")
						end
				elseif rand >73 and rand <=78 then
					doPlayerAddItem(cid,1294,2)
					doPlayerSendTextMessage(cid,22,"You have found 2 stones!")
				elseif rand >78 and rand <85 then
					doTransformItem(item2.uid, 4329)
					doDecayItem(item2.uid)
					doPlayerSendTextMessage(cid,22,"This mine is empty!")
				elseif rand >=85 and rand <=100 then
					doPlayerSendTextMessage(cid,22,"Found nothing!")
				end
			else
				doRemoveItem(item.uid,1)
				doSendMagicEffect(topos,2)
				setPlayerStorageValue(cid,40004,0)
				doPlayerSendTextMessage(cid,22,"Your pick has been damaged and broke...")			
			end
			

------- start next miningskill stage here (start with elseif) ------

------- miningskills end here

		end
	elseif item2.itemid == 4329 then
		doPlayerSendTextMessage(cid,22,"This mine is empty!")
	elseif playerSkillMine < 1 then
		doPlayerSendTextMessage(cid,22,"You need to learn mining first!")
	else
	doPlayerSendTextMessage(cid,22,"You need to be in a Mine!")
	end
end

- You can change Storage IDs
- You can change multipler (now its 1.5) remember to change this also in mining.lua (talkactions) else percent for skillup will not be right!
- You can change pickBrocken (now its between 20 and 40)

action.xml (remember to delete all others using item id 2553)
Code:
<action itemid="2553" script="other/mining.lua" />

mining.lua (Talkactions)
Code:
function onSay(cid, words, param)
playerSkillMine = getPlayerStorageValue(cid, 40002) 
	if getPlayerStorageValue(cid, 40001) > 0 then
			playerMineTry = getPlayerStorageValue(cid, 40003)
			tmp = math.ceil(playerSkillMine*playerSkillMine*1.5)
			percentNextSkillTmp = math.ceil(100 / tmp * playerMineTry)
			percentNextSkill = 100-percentNextSkillTmp
			nextSkill = playerSkillMine+1
			if percentNextSkill > 0 then
				doPlayerSendTextMessage(cid,22,"You Miningskill is "..playerSkillMine.." now! For Skill "..nextSkill.." you have "..percentNextSkill.."% to go")
			else
				doPlayerSendTextMessage(cid,22,"You Miningskill is "..playerSkillMine.." now! For Skill "..nextSkill.." you have 1% to go")
			end		
	else
		doPlayerSendCancel(cid, "You dont know how to mine!.")
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	end
end

talkaction.xml
Code:
<talkaction words="!mining" script="mining.lua"/>

items.xml
Code:
<item id="4328" name="mining ground">
</item>
<item id="4329" name="empty mining ground">
	<attribute key="decayTo" value="4328"/>
	<attribute key="duration" value="240"/>
</item>

If you have done all, it should work!
Hope you like it!

Virgel
 
This script looks really nice!
Does It work for a TFS 0.2.7 server?
Rep anyways.
 
I need you to add that NPC, seems to be working fine otherwise.
A chest which gives you a pick and the storage would be better.
 
Last edited:
add this to your login script.

LUA:
	local sn,so = {40001,40003,40004),{40002} --nil storage, 1 storage.
	for _,s in ipairs(sn) do
		if getPlayerStorageValue(cid,s) < 0 then
			setPlayerStorageValue(cid,s,0)
		end
	end
	
	for _,o in ipairs(so) do
		if getPlayerStorageValue(cid,o) < 1 then
			setPlayerStorageValue(cid,o,1)
		end
	end
 
Back
Top