ziggy46802
Active Member
- Joined
- Aug 19, 2012
- Messages
- 418
- Reaction score
- 27
Put this script in data/actions/scripts
rockmining.lua
I know its a pretty basic code but I bet some people will get some use out of it. Tell me if there are any errors or you want me to add to it.
You have to go to actions.xml and add
8636 is the id of the rock to be mined
rockmining.lua
Code:
function restore(cid)
setPlayerStorageValue(cid, 1025, 1)
end
function onUse(cid, item, frompos, item2, topos)
if getPlayerStorageValue(cid, 1025) < 2 -- storage id to use (dont mess with unless you know what you are doing)
then
setPlayerStorageValue(cid, 1025, 2) -- sets storage so that it knows to "kill" the rock
doSendMagicEffect(getPlayerPosition(cid), 13) -- send sparkles on you
doCreatureSay(cid, "You have come across a precious stone.", TALKTYPE_ORANGE_1) -- text pops up
doPlayerAddItem(cid, 5953, (math.random(1, 3))) --change 5953 to id of item you want to get (like a small ruby or small emerald) and change (math.random(1,3)) to the lowest and highest you want it to give you
else -- if rock is dead
doCreatureSay(cid, "This rock has already been mined.", TALKTYPE_ORANGE_1) -- text pops up
addEvent(restore, (math.random(15,120)) * 60 * 1000, cid) -- you can change the whole "(math.random(15,120))" to a certain number of minutes you want it to "respawn" or set it like this and it will take a random time between 15 minutes and 2 hours.
end
end
I know its a pretty basic code but I bet some people will get some use out of it. Tell me if there are any errors or you want me to add to it.
You have to go to actions.xml and add
Code:
<action itemid="8636" script="rockmining.lua"/>