Piquenoelmal
I'm in an eternal depression
Hello!
I'm using a simple script for mining. I made some changes and it's possible to use a Pick in a rock(1295), then the rock turns to debris and you gather an item.
My problem here is that the rock that turn to debris doesn't re spawn again, even when I made a function to do so. And the other problem is that the skill("club" for now), doesn't receive the exp(tries) to it.
Here is the code.
I'm using a simple script for mining. I made some changes and it's possible to use a Pick in a rock(1295), then the rock turns to debris and you gather an item.
My problem here is that the rock that turn to debris doesn't re spawn again, even when I made a function to do so. And the other problem is that the skill("club" for now), doesn't receive the exp(tries) to it.
Here is the code.
Lua:
local config = {
stones = {1285},
t = {
[{1, 100}] = {tree = 1285}
},
level = 20, skill = SKILL_CLUB, skillReq = 15, effect = CONST_ME_BLOCKHIT, addTries = 100, debris = 1336, msgType = MESSAGE_EVENT_ADVANCE, soul = 1, minutes = 0
}
local t = {
[{1, 10000}] = {msg = "You mined an Iron Ore.", item = 5880, amountmax = 3},
--[{101, 200}] = {msg = "Your pick broke...", destroy = true}
}
local function newStones(parameter)
local stone = getThingfromPos{x = parameter.position.x, y = parameter.position.y, z = parameter.position.z, stackpos = 1}
for i2, k2 in pairs(config.t) do
local v2 = math.random(1500), 1, nil
if v2 >= i2[1] and v2 <= i2[2] then
if k2.stone then
if (stone.itemid == config.debris) then
doTransformItem(stone.uid, k2.stone)
end
end
end
end
end
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) and config.soul <= getPlayerSoul(cid) 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.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
doPlayerSendTextMessage(cid, config.msgType, msg)
end
addEvent(newStones, config.minutes*60*1000, {position = toPosition, cid = cid})
doTransformItem(itemEx.uid, config.debris)
doPlayerAddSoul(cid, -config.soul)
doSendMagicEffect(toPosition, k.destroy and CONST_ME_HITAREA or config.effect)
return doPlayerAddSkillTry(cid, config.skill, config.addTries)
end
end
end
return doPlayerSendCancel(cid, "It's not possible.")
end
Last edited: