ZL

Magic Wall

Por zllcapiroto, 27 de mar. de 2023 em Scripts

2
1.2k
zllcapirotoZ
27 de março de 2023 às 11:40

Boa rapaziada.

 

A magic wall rune tem duração de 20 segundos, gostaria de saber como colocar ela pra quando faltar 5 segundos o tempo acabar aleatoriamente, se alguém puder ajudar, agradeço!

3 meses depois...
L3K0TL
28 de junho de 2023 às 05:38

Actions

 

local duration = 20000 -- Duração total em milissegundos
local warningTime = 5000 -- 5 segundos antes do fim

function onUse(cid, item, fromPosition, itemEx, toPosition)
    item:setAttribute(ITEM_ATTRIBUTE_DURATION, duration) -- Define a duração inicial da Magic Wall Rune

    addEvent(function(item)
        local remainingTime = item:getAttribute(ITEM_ATTRIBUTE_DURATION) - warningTime
        if remainingTime > 0 then
            item:setAttribute(ITEM_ATTRIBUTE_DURATION, remainingTime) -- Reduz a duração em 5 segundos
            item:getPosition():sendMagicEffect(CONST_ME_POFF) -- Efeito visual indicando o tempo restante
        else
            item:remove() -- Remove a Magic Wall Rune quando o tempo acabar aleatoriamente
        end
    end, warningTime, item)

    -- Restante do código da função onUse, se houver...
end