Ir para conteúdo

Featured Replies

Postado
  • Solução

Entedi, só mudar o target:transform(12706), por:

target:remove()
Game.createItem(12706, 1, toPosition)

 

Script inteiro:

local rewards = {
    { item = 8298, count = 1, chance = 50 },
    { item = 8299, count = 1, chance = 50 },
    { item = 8301, count = 1, chance = 50 },
    { item = 8302, count = 1, chance = 50 },
    { item = 8303, count = 1, chance = 50 },
    { item = 8310, count = 1, chance = 50 },
    { item = 9971, count = 1, chance = 50 },
    { item = 5944, count = 1, chance = 100 }
}

local storage = 5000
local delay_timer = 5

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    
    local cur_time, cur_storage = os.time(), player:getStorageValue(storage)
 
    if cur_storage > cur_time then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can mining again in " .. os.date("!%Hh %Mm %Ss", cur_storage - cur_time) .. ".")
        return true
    end

    local function addBackStone()
	local tRocks = getTileItemById(toPosition, 12706)
		if tRocks then
		doRemoveItem(tRocks.uid, 1)
		local stones = {12705}
		local stone = Game.createItem(stones[math.random(#stones)], 1, toPosition)
			if stone then
				stone:setActionId(40041)
			end
		end
	end
    
    
    if not target then
        return false
    end
    
    if not target:isItem() then
        return false
    end

    if target.actionid ~= 40041 then
    local pos = player:getPosition()
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You cannot use it here.')
        return false
    end
    
    if target.actionid == 40041 then
    local ran = math.random(100)
        if ran <= 10 then
            toPosition:sendMagicEffect(3)
            target:remove()
            Game.createItem(12706, 1, toPosition)
            addEvent(addBackStone, 120000)
            return true
        end
    end
 
    local text = "You have found "
    for i = 1, #rewards do
        local rand = math.random(1000)
        if rand <= rewards[i].chance then
            player:addItem(rewards[i].item, rewards[i].count)
            if text ~= "You have found " then
                text = text .. ", "
            end
            text = text .. rewards[i].count .. " " .. ItemType(rewards[i].item):getName()
        end         
    end
    if text == "You have found " then
        text = text .. "nothing"
    end
    player:sendTextMessage(36, text .. ".")
    cur_time = cur_time + delay_timer
    player:setStorageValue(storage, cur_time)
    return true
end

 

  • Respostas 6
  • Visualizações 727
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Da uma testada ai. Eu acho q vai funcionar assim.   local rewards = { { item = 8298, count = 1, chance = 50 }, { item = 8299, count = 1, chance = 50 }, { item = 8301, count = 1, c

  • Entedi, só mudar o target:transform(12706), por: target:remove() Game.createItem(12706, 1, toPosition)   Script inteiro: local rewards = { { item = 8298, count = 1, chance = 50 },

Posted Images

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo