I need to adapt this code to be used with a pick.
I also need the character to be unable to move for twenty seconds, unable to use spells, unable to attack, and finally, unable to leave the game ...
And one more thing ... When the stone is mined, I need another one to appear at the site after twenty minutes.
Currently, this is my script:
I also need the character to be unable to move for twenty seconds, unable to use spells, unable to attack, and finally, unable to leave the game ...
And one more thing ... When the stone is mined, I need another one to appear at the site after twenty minutes.
Currently, this is my script:
Lua:
local stone_id = 19959
function vinteMinutos(toPosition) -- Recreate the stone after 20 minutes.
Game.createItem(stone_id, 1, toPosition)
return true
end
function vinteVezes(playerID, toPosition) -- Repeat this function every second. Repeat this twenty times.
local player = Player(playerID)
if player:getStorageValue(mining) <= 20 then
toPosition:sendMagicEffect(CONST_ME_BLOCKHIT) -- Effect while mining.
player:setStorageValue(mining, player:getStorageValue(mining) + 1)
player:addItem(2225, 1, true) -- Piece of Iron
addEvent(vinteVezes, 1 * 1000, playerID, toPosition) -- Perform this function after 1 second.
else
-- Remove stone.
player:setStorageValue(mining, 0)
player:setStorageValue(started, 0)
addEvent(vinteMinutos, 20 * 60 * 1000, toPosition) -- Perform this function after 20 minutes.
end
return true
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local miningSkill = player:getStorageValue(SKILL_MINERADOR)
local random = math.random(1, 100000)
local chance = (miningSkill / 1.5)
if player:getStorageValue(started) == 1 then
player.sendCancelMessage(player, "Ja esta minerando.")
else
if chance < 10000 then chance = 10000 end
if random <= chance then
player:setStorageValue(ESTIMA, getPlayerStorageValue(player, ESTIMA) + 1) -- Adds a reputation point.
player:setStorageValue(started, 1)
vinteVezes(player:getId(), toPosition)
local G_SKILL_MINERADOR = player:getStorageValue(SKILL_MINERADOR)
local max = 100000
if math.random(1, max) <= (max / (G_SKILL_MINERADOR / 4)) then
player:setStorageValue(SKILL_MINERADOR, G_SKILL_MINERADOR + 1)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Habilidade como minerador: ".. G_SKILL_MINERADOR ..".")
end
else
toPosition:sendMagicEffect(CONST_ME_POFF) -- Effect while mining.
player.sendCancelMessage(player, "Falha.")
addEvent(vinteMinutos, 20 * 60 * 1000, toPosition) -- Perform this function after 20 minutes.
end
end
return true
end
-- To do:
-- It makes it impossible for the character to move for twenty seconds.
-- It makes it impossible for the character to use spells for twenty seconds.
-- Impossible for the character to attack for twenty seconds.
-- It prevents the character from leaving the game for twenty seconds.