• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua -=[TFS]=- 0.4 8.60 Script no Show Contdown and no Function Time 30 Minutes use it on the item and the green countdown will appear

samuel157

/root
Joined
Mar 19, 2010
Messages
447
Solutions
3
Reaction score
49
Location
São Paulo, Brazil
GitHub
Samuel10M
Lua:
local storageValue = 13741
local itemID = 8981 -- Item utilizado para conceder o acesso de 30 minutos
local teleportPosition = {x = 154, y = 51, z = 7} -- Posição de teleporte quando o tempo acabar
local cooldownTime = 30 * 60 -- Tempo de cooldown em segundos (30 minutos)
local timeInterval = 60 -- Intervalo de verificação de tempo em segundos (exemplo: 1 minuto)

function onUse(cid, item, frompos, item2, topos)
    local lastUsageTime = getPlayerStorageValue(cid, "lastUsageTime")
    local currentTime = os.time()

    if lastUsageTime ~= -1 and currentTime < lastUsageTime + cooldownTime then
        local remainingTime = (lastUsageTime + cooldownTime) - currentTime
        local minutes = math.floor(remainingTime / 60)
        local seconds = remainingTime % 60

        doPlayerSendCancel(cid, "Aguarde mais " .. minutes .. " minutos e " .. seconds .. " segundos antes de usar novamente.")
        return true
    end

    if getPlayerStorageValue(cid, storageValue) ~= -1 then
        doPlayerSendCancel(cid, "Você já tem acesso a essa funcionalidade.")
        return true
    end

    if not doPlayerRemoveItem(cid, itemID, 1) then
        doPlayerSendCancel(cid, "Você precisa ter o item necessário para usar essa funcionalidade.")
        return true
    end

    local expirationTime = currentTime + (30 * 60) -- Convertendo 30 minutos para segundos

    setPlayerStorageValue(cid, storageValue, expirationTime)
    setPlayerStorageValue(cid, "lastUsageTime", currentTime)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você ganhou acesso a essa funcionalidade por 30 minutos.")

    return true
end

function onLogin(cid)
    local currentTime = os.time()
    local expirationTime = getPlayerStorageValue(cid, storageValue)

    if expirationTime ~= -1 and currentTime >= expirationTime then
        doTeleportThing(cid, teleportPosition, false)
        setPlayerStorageValue(cid, storageValue, -1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Seu acesso expirou. Você foi teleportado para a posição 154, 51, 7.")
    end

    local lastTimeCheck = getPlayerStorageValue(cid, "lastTimeCheck")
    local timeDifference = currentTime - lastTimeCheck

    if timeDifference >= timeInterval then
        local timeRemaining = expirationTime - currentTime
        if timeRemaining > 0 then
            local minutes = math.floor(timeRemaining / 60)
            local seconds = timeRemaining % 60

            local timeString = string.format("%02d:%02d", minutes, seconds)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Tempo restante: " .. timeString)
        end

        setPlayerStorageValue(cid, "lastTimeCheck", currentTime)
    end

    return true
end
 
I made three different scripts. Which one do you like the most? Take a look at the images
Lua:
local storageValue = 13741

local itemID = 8981 -- Item utilizado para conceder o acesso de 30 minutos

local teleportPosition = {x = 154, y = 51, z = 7} -- Posição de teleporte quando o tempo acabar

local cooldownTime = 30 * 60 -- Tempo de cooldown em segundos (30 minutos)

local timeInterval = 60 -- Intervalo de verificação de tempo em segundos (exemplo: 1 minuto)



function onUse(cid, item, frompos, item2, topos)

    local lastUsageTime = getPlayerStorageValue(cid, "lastUsageTime")

    local currentTime = os.time()



    if lastUsageTime ~= -1 and currentTime < lastUsageTime + cooldownTime then

        local remainingTime = (lastUsageTime + cooldownTime) - currentTime

        local minutes = math.floor(remainingTime / 60)

        local seconds = remainingTime % 60



        doPlayerPopupFYI(cid, "Aguarde mais " .. minutes .. " minutos e " .. seconds .. " segundos antes de usar novamente!")

        return true

    end



    if getPlayerStorageValue(cid, storageValue) ~= -1 then

        doPlayerPopupFYI(cid, "Você já tem acesso a essa funcionalidade.")

        return true

    end



    local hasUnlimitedCharges = getPlayerStorageValue(cid, "hasUnlimitedCharges") == 1



    if not hasUnlimitedCharges and not doPlayerRemoveItem(cid, itemID, 1) then

        doPlayerPopupFYI(cid, "Você precisa ter o item necessário para usar essa funcionalidade.")

        return true

    end



    local expirationTime = currentTime + (30 * 60) -- Convertendo 30 minutos para segundos



    setPlayerStorageValue(cid, storageValue, expirationTime)

    setPlayerStorageValue(cid, "lastUsageTime", currentTime)

    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você ganhou acesso a essa funcionalidade por 30 minutos.")



    return true

end



function onLogin(cid)

    local currentTime = os.time()

    local expirationTime = getPlayerStorageValue(cid, storageValue)



    if expirationTime ~= -1 and currentTime >= expirationTime then

        doTeleportThing(cid, teleportPosition, false)

        setPlayerStorageValue(cid, storageValue, -1)

        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Seu acesso expirou. Você foi teleportado para a posição 154, 51, 7.")

    end



    local lastTimeCheck = getPlayerStorageValue(cid, "lastTimeCheck")

    local timeDifference = currentTime - lastTimeCheck



    if timeDifference >= timeInterval then

        local timeRemaining = expirationTime - currentTime

        if timeRemaining > 0 then

            local minutes = math.floor(timeRemaining / 60)

            local seconds = timeRemaining % 60



            local timeString = string.format("%02d:%02d", minutes, seconds)

            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Tempo restante: " .. timeString)

        end



        setPlayerStorageValue(cid, "lastTimeCheck", currentTime)

    end



    return true

end
or
Lua:
local storageValue = 13741

local itemID = 8981 -- Item utilizado para conceder o acesso de 30 minutos

local teleportPosition = {x = 154, y = 51, z = 7} -- Posição de teleporte quando o tempo acabar

local cooldownTime = 30 * 60 -- Tempo de cooldown em segundos (30 minutos)

local timeInterval = 60 -- Intervalo de verificação de tempo em segundos (exemplo: 1 minuto)



function onUse(cid, item, frompos, item2, topos)

    local lastUsageTime = getPlayerStorageValue(cid, "lastUsageTime")

    local currentTime = os.time()



    if lastUsageTime ~= -1 and currentTime < lastUsageTime + cooldownTime then

        local remainingTime = (lastUsageTime + cooldownTime) - currentTime

        local minutes = math.floor(remainingTime / 60)

        local seconds = remainingTime % 60



        doCreatureSay(cid, "Aguarde mais " .. minutes .. " minutos e " .. seconds .. " segundos antes de usar novamente!", TALKTYPE_ORANGE_1)

        return true

    end



    if getPlayerStorageValue(cid, storageValue) ~= -1 then

        doCreatureSay(cid, "Você já tem acesso a essa funcionalidade.", TALKTYPE_ORANGE_1)

        return true

    end



    local hasUnlimitedCharges = getPlayerStorageValue(cid, "hasUnlimitedCharges") == 1



    if not hasUnlimitedCharges and not doPlayerRemoveItem(cid, itemID, 1) then

        doCreatureSay(cid, "Você precisa ter o item necessário para usar essa funcionalidade.", TALKTYPE_ORANGE_1)

        return true

    end



    local expirationTime = currentTime + (30 * 60) -- Convertendo 30 minutos para segundos



    setPlayerStorageValue(cid, storageValue, expirationTime)

    setPlayerStorageValue(cid, "lastUsageTime", currentTime)

    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você ganhou acesso a essa funcionalidade por 30 minutos.")



    return true

end



function onLogin(cid)

    local currentTime = os.time()

    local expirationTime = getPlayerStorageValue(cid, storageValue)



    if expirationTime ~= -1 and currentTime >= expirationTime then

        doTeleportThing(cid, teleportPosition, false)

        setPlayerStorageValue(cid, storageValue, -1)

        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Seu acesso expirou. Você foi teleportado para a posição 154, 51, 7.")

    end



    local lastTimeCheck = getPlayerStorageValue(cid, "lastTimeCheck")

    local timeDifference = currentTime - lastTimeCheck



    if timeDifference >= timeInterval then

        local timeRemaining = expirationTime - currentTime

        if timeRemaining > 0 then

            local minutes = math.floor(timeRemaining / 60)

            local seconds = timeRemaining % 60



            local timeString = string.format("%02d:%02d", minutes, seconds)

            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Tempo restante: " .. timeString)

        end



        setPlayerStorageValue(cid, "lastTimeCheck", currentTime)

    end



    return true

end
or
Lua:
local storageValue = 13741

local itemID = 8981 -- Item utilizado para conceder o acesso de 30 minutos

local teleportPosition = {x = 154, y = 51, z = 7} -- Posição de teleporte quando o tempo acabar

local cooldownTime = 30 * 60 -- Tempo de cooldown em segundos (30 minutos)

local timeInterval = 60 -- Intervalo de verificação de tempo em segundos (exemplo: 1 minuto)



function onUse(cid, item, frompos, item2, topos)

    local lastUsageTime = getPlayerStorageValue(cid, "lastUsageTime")

    local currentTime = os.time()



    if lastUsageTime ~= -1 and currentTime < lastUsageTime + cooldownTime then

        local remainingTime = (lastUsageTime + cooldownTime) - currentTime

        local minutes = math.floor(remainingTime / 60)

        local seconds = remainingTime % 60



        doPlayerSendCancel(cid, "Aguarde mais " .. minutes .. " minutos e " .. seconds .. " segundos antes de usar novamente.")

        return true

    end



    if getPlayerStorageValue(cid, storageValue) ~= -1 then

        doPlayerSendCancel(cid, "Você já tem acesso a essa funcionalidade.")

        return true

    end



    local hasUnlimitedCharges = getPlayerStorageValue(cid, "hasUnlimitedCharges") == 1



    if not hasUnlimitedCharges and not doPlayerRemoveItem(cid, itemID, 1) then

        doPlayerSendCancel(cid, "Você precisa ter o item necessário para usar essa funcionalidade.")

        return true

    end



    local expirationTime = currentTime + (30 * 60) -- Convertendo 30 minutos para segundos



    setPlayerStorageValue(cid, storageValue, expirationTime)

    setPlayerStorageValue(cid, "lastUsageTime", currentTime)

    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você ganhou acesso a essa funcionalidade por 30 minutos.")



    return true

end



function onLogin(cid)

    local currentTime = os.time()

    local expirationTime = getPlayerStorageValue(cid, storageValue)



    if expirationTime ~= -1 and currentTime >= expirationTime then

        doTeleportThing(cid, teleportPosition, false)

        setPlayerStorageValue(cid, storageValue, -1)

        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Seu acesso expirou. Você foi teleportado para a posição 154, 51, 7.")

    end



    local lastTimeCheck = getPlayerStorageValue(cid, "lastTimeCheck")

    local timeDifference = currentTime - lastTimeCheck



    if timeDifference >= timeInterval then

        local timeRemaining = expirationTime - currentTime

        if timeRemaining > 0 then

            local minutes = math.floor(timeRemaining / 60)

            local seconds = timeRemaining % 60



            local timeString = string.format("%02d:%02d", minutes, seconds)

            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Tempo restante: " .. timeString)

        end



        setPlayerStorageValue(cid, "lastTimeCheck", currentTime)

    end



    return true

end
 

Attachments

  • mostrar tempo.png
    mostrar tempo.png
    151.7 KB · Views: 12 · VirusTotal
  • mostrar tempo2.png
    mostrar tempo2.png
    352.7 KB · Views: 12 · VirusTotal
  • mostrar tempo3.png
    mostrar tempo3.png
    367.9 KB · Views: 12 · VirusTotal
Lua:
local storageValue = 13741

local itemID = 8981 -- Item utilizado para conceder o acesso de 30 minutos

local teleportPosition = {x = 154, y = 51, z = 7} -- Posição de teleporte quando o tempo acabar

local cooldownTime = 30 * 60 -- Tempo de cooldown em segundos (30 minutos)

local timeInterval = 60 -- Intervalo de verificação de tempo em segundos (exemplo: 1 minuto)



function onUse(cid, item, frompos, item2, topos)

    local lastUsageTime = getPlayerStorageValue(cid, "lastUsageTime")

    local currentTime = os.time()



    if lastUsageTime ~= -1 and currentTime < lastUsageTime + cooldownTime then

        local remainingTime = (lastUsageTime + cooldownTime) - currentTime

        local minutes = math.floor(remainingTime / 60)

        local seconds = remainingTime % 60



        doCreatureSay(cid, "Aguarde mais " .. minutes .. " minutos e " .. seconds .. " segundos antes de usar novamente!", TALKTYPE_ORANGE_1)

        return true

    end



    if getPlayerStorageValue(cid, storageValue) ~= -1 then

        doCreatureSay(cid, "Você já tem acesso a essa funcionalidade.", TALKTYPE_ORANGE_1)

        return true

    end



    local hasUnlimitedCharges = getPlayerStorageValue(cid, "hasUnlimitedCharges") == 1



    if not hasUnlimitedCharges and not doPlayerRemoveItem(cid, itemID, 1) then

        doCreatureSay(cid, "Você precisa ter o item necessário para usar essa funcionalidade.", TALKTYPE_ORANGE_1)

        return true

    end



    local expirationTime = currentTime + (30 * 60) -- Convertendo 30 minutos para segundos



    setPlayerStorageValue(cid, storageValue, expirationTime)

    setPlayerStorageValue(cid, "lastUsageTime", currentTime)

    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você ganhou acesso a essa funcionalidade por 30 minutos.")



    return true

end



function onLogin(cid)

    local currentTime = os.time()

    local expirationTime = getPlayerStorageValue(cid, storageValue)



    if expirationTime ~= -1 and currentTime >= expirationTime then

        doTeleportThing(cid, teleportPosition, false)

        setPlayerStorageValue(cid, storageValue, -1)

        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Seu acesso expirou. Você foi teleportado para a posição 154, 51, 7.")

    end



    local lastTimeCheck = getPlayerStorageValue(cid, "lastTimeCheck")

    local timeDifference = currentTime - lastTimeCheck



    if timeDifference >= timeInterval then

        local timeRemaining = expirationTime - currentTime

        if timeRemaining > 0 then

            local minutes = math.floor(timeRemaining / 60)

            local seconds = timeRemaining % 60



            local timeString = string.format("%02d:%02d", minutes, seconds)

            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Tempo restante: " .. timeString)

        end



        setPlayerStorageValue(cid, "lastTimeCheck", currentTime)

    end



    return true

end

I WOULD LIKE TO SHOW THIS ON THE DISPLAY ONLY IN THE CASE 30 MINUTES 60 SECONDS.

script bug. and no function kick automatic
xp.thumb.gif.131eae7c6daac03477fa82ecc472bc2c.gif
 
Last edited:
I fixed the script!!

Lua:
local storageValue = 13741
local itemID = 8981 -- Item utilizado para conceder o acesso de 30 minutos
local teleportPosition = {x = 154, y = 51, z = 7} -- Posição de teleporte quando o tempo acabar
local cooldownTime = 30 * 60 -- Tempo de cooldown em segundos (30 minutos)
local timeInterval = 60 -- Intervalo de verificação de tempo em segundos (exemplo: 1 minuto)

function onUse(cid, item, frompos, item2, topos)
    local lastUsageTime = getPlayerStorageValue(cid, "lastUsageTime")
    local currentTime = os.time()

    if lastUsageTime ~= -1 and currentTime < lastUsageTime + cooldownTime then
        local remainingTime = (lastUsageTime + cooldownTime) - currentTime
        local minutes = math.floor(remainingTime / 60)
        local seconds = remainingTime % 60

      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Aguarde mais " .. minutes .. " minutos e " .. seconds .. " segundos antes de usar novamente!")

        return true
    end

    if getPlayerStorageValue(cid, storageValue) ~= -1 then
        doPlayerPopupFYI(cid, "Você já tem acesso a essa funcionalidade.")
        return true
    end

    local hasUnlimitedCharges = getPlayerStorageValue(cid, "hasUnlimitedCharges") == 1

    if not hasUnlimitedCharges and not doPlayerRemoveItem(cid, itemID, 1) then
        doPlayerPopupFYI(cid, "Você precisa ter o item necessário para usar essa funcionalidade.")
        return true
    end

    local expirationTime = currentTime + (30 * 60) -- Convertendo 30 minutos para segundos

    setPlayerStorageValue(cid, storageValue, expirationTime)
    setPlayerStorageValue(cid, "lastUsageTime", currentTime)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você ganhou acesso a essa funcionalidade por 30 minutos.")

    return true
end

function onLogin(cid)
    local currentTime = os.time()
    local expirationTime = getPlayerStorageValue(cid, storageValue)

    if expirationTime ~= -1 and currentTime >= expirationTime then
        doTeleportThing(cid, teleportPosition, false)
        setPlayerStorageValue(cid, storageValue, -1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Seu acesso expirou. Você foi teleportado para a posição 154, 51, 7.")
    end

    local lastTimeCheck = getPlayerStorageValue(cid, "lastTimeCheck")
    local timeDifference = currentTime - lastTimeCheck

    if timeDifference >= timeInterval then
        local timeRemaining = expirationTime - currentTime
        if timeRemaining > 0 then
            local minutes = math.floor(timeRemaining / 60)
            local seconds = timeRemaining % 60

            local timeString = string.format("%02d:%02d", minutes, seconds)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Tempo restante: " .. timeString)
        end

        setPlayerStorageValue(cid, "lastTimeCheck", currentTime)
    end

    return true
end
In case you want to make changes to the colors, the information is here
MESSAGE_FIRST = 18
MESSAGE_STATUS_CONSOLE_RED = MESSAGE_FIRST
MESSAGE_EVENT_ORANGE = 19
MESSAGE_STATUS_CONSOLE_ORANGE = 20
MESSAGE_STATUS_WARNING = 21
MESSAGE_EVENT_ADVANCE = 22
MESSAGE_EVENT_DEFAULT = 23
MESSAGE_STATUS_DEFAULT = 24
MESSAGE_INFO_DESCR = 25
MESSAGE_STATUS_SMALL = 26
MESSAGE_STATUS_CONSOLE_BLUE = 27
MESSAGE_LAST = MESSAGE_STATUS_CONSOLE_BLUE

MESSAGE_TYPES = {
["advance"] = MESSAGE_EVENT_ADVANCE,
["event"] = MESSAGE_EVENT_DEFAULT,
["white"] = MESSAGE_EVENT_DEFAULT,
["orange"] = MESSAGE_STATUS_CONSOLE_ORANGE,
["info"] = MESSAGE_INFO_DESCR,
["green"] = MESSAGE_INFO_DESCR,
["small"] = MESSAGE_STATUS_SMALL,
["blue"] = MESSAGE_STATUS_CONSOLE_BLUE,
["red"] = MESSAGE_STATUS_CONSOLE_RED,
["warning"] = MESSAGE_STATUS_WARNING,
["status"] = MESSAGE_STATUS_DEFAULT}
 
is there a way to make an item disappear when using it and the countdown show starts and no function kick Then buy the new gold newspaper with vip coin on the lever to gain access to the VIP area

ACTION:


Lua:
local storageValue = 13741
local itemID = 8981 -- Item utilizado para conceder o acesso de 30 minutos
local teleportPosition = {x = 154, y = 51, z = 7} -- Posição de teleporte quando o tempo acabar
local cooldownTime = 30 * 60 -- Tempo de cooldown em segundos (30 minutos)
local timeInterval = 60 -- Intervalo de verificação de tempo em segundos (exemplo: 1 minuto)

function onUse(cid, item, frompos, item2, topos)
    local lastUsageTime = getPlayerStorageValue(cid, "lastUsageTime")
    local currentTime = os.time()

    if lastUsageTime ~= -1 and currentTime < lastUsageTime + cooldownTime then
        local remainingTime = (lastUsageTime + cooldownTime) - currentTime
        local minutes = math.floor(remainingTime / 60)
        local seconds = remainingTime % 60

      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Aguarde mais " .. minutes .. " minutos e " .. seconds .. " segundos antes de usar novamente!")

        return true
    end

    if getPlayerStorageValue(cid, storageValue) ~= -1 then
        doPlayerPopupFYI(cid, "Você já tem acesso a essa funcionalidade.")
        return true
    end

    local hasUnlimitedCharges = getPlayerStorageValue(cid, "hasUnlimitedCharges") == 1

    if not hasUnlimitedCharges and not doPlayerRemoveItem(cid, itemID, 1) then
        doPlayerPopupFYI(cid, "Você precisa ter o item necessário para usar essa funcionalidade.")
        return true
    end

    local expirationTime = currentTime + (30 * 60) -- Convertendo 30 minutos para segundos

    setPlayerStorageValue(cid, storageValue, expirationTime)
    setPlayerStorageValue(cid, "lastUsageTime", currentTime)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você ganhou acesso a essa funcionalidade por 30 minutos.")

    return true
end

function onLogin(cid)
    local currentTime = os.time()
    local expirationTime = getPlayerStorageValue(cid, storageValue)

    if expirationTime ~= -1 and currentTime >= expirationTime then
        doTeleportThing(cid, teleportPosition, false)
        setPlayerStorageValue(cid, storageValue, -1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Seu acesso expirou. Você foi teleportado para a posição 154, 51, 7.")
    end

    local lastTimeCheck = getPlayerStorageValue(cid, "lastTimeCheck")
    local timeDifference = currentTime - lastTimeCheck

    if timeDifference >= timeInterval then
        local timeRemaining = expirationTime - currentTime
        if timeRemaining > 0 then
            local minutes = math.floor(timeRemaining / 60)
            local seconds = timeRemaining % 60

            local timeString = string.format("%02d:%02d", minutes, seconds)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Tempo restante: " .. timeString)
        end

        setPlayerStorageValue(cid, "lastTimeCheck", currentTime)
    end

    return true
end


MOVEMENTS:

Lua:
function onStepIn(cid, item, position, fromPosition)

local sto = 13741 -- storage Aqui

 if isPlayer(cid) then
   if getPlayerStorageValue(cid, sto) >= 1 then
     doPlayerSendTextMessage(cid, 25, "Seja bem vindo a area.")
       else
         doTeleportThing(cid, fromPosition, true)
       doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
      doPlayerSendTextMessage(cid, 25, "Voce Nao Tem Acesso!")
   end
 end
 
return true
end
 
Last edited:
Yes there is a way! The text is animated. You didn't mention it before, I added some functions. Now, when you click on the item, the text disappears and reappears in animated format, accompanied by a countdown

Lua:
local storageValue = 13741
local itemID = 8981
local teleportPosition = {x = 154, y = 51, z = 7}
local cooldownTime = 30 * 60
local timeInterval = 60
local countdownTextEffect = 21
local animetextEffect = 67
local animetextEffectInterval = 5

function sendBuffActiveText(cid, remainingTime)
    local minutes = math.floor(remainingTime / 60)
    local seconds = remainingTime % 60

    doSendAnimatedText(getCreaturePosition(cid), "Aguarde mais " .. minutes .. " minutos e " .. seconds .. " segundos", animetextEffect)

    if remainingTime > 0 then
        addEvent(sendBuffActiveText, animetextEffectInterval * 1000, cid, remainingTime - animetextEffectInterval)
    end
end

function sendCountdownText(cid, remainingTime)
    local minutes = math.floor(remainingTime / 60)
    local seconds = remainingTime % 60

    doSendAnimatedText(getCreaturePosition(cid), "Aguarde mais " .. minutes .. " minutos e " .. seconds .. " segundos", countdownTextEffect)
end

function onUse(cid, item, frompos, item2, topos)
    local lastUsageTime = getPlayerStorageValue(cid, "lastUsageTime")
    local currentTime = os.time()

    if lastUsageTime ~= -1 and currentTime < lastUsageTime + cooldownTime then
        local remainingTime = (lastUsageTime + cooldownTime) - currentTime
        sendCountdownText(cid, remainingTime)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Aguarde mais " .. math.floor(remainingTime / 60) .. " minutos e " .. remainingTime % 60 .. " segundos antes de usar novamente.")
        return true
    end

    if getPlayerStorageValue(cid, storageValue) ~= -1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você já tem acesso a essa funcionalidade.")
        return true
    end

    local hasUnlimitedCharges = getPlayerStorageValue(cid, "hasUnlimitedCharges") == 1

    if not hasUnlimitedCharges and not doPlayerRemoveItem(cid, itemID, 1) then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você precisa ter o item necessário para usar essa funcionalidade.")
        return true
    end

    local expirationTime = currentTime + (30 * 60)

    setPlayerStorageValue(cid, storageValue, expirationTime)
    setPlayerStorageValue(cid, "lastUsageTime", currentTime)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você ganhou acesso a essa funcionalidade por 30 minutos.")

    sendCountdownText(cid, 30 * 60)

    addEvent(function()
        if isPlayer(cid) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Seu tempo de acesso expirou.")
            doTeleportThing(cid, teleportPosition)
            setPlayerStorageValue(cid, storageValue, -1)
        end
    end, cooldownTime * 1000)

    addEvent(function()
        if isPlayer(cid) then
            local remainingTime = (getPlayerStorageValue(cid, storageValue) - os.time())
            sendBuffActiveText(cid, remainingTime)
        end
    end, animetextEffectInterval * 1000)

    return true
end

If you want to increase the time for the animated text to appear, just change the number from 5 to 10 or any other value you like.
local animetextEffectInterval = 10

f you want to exchange for another color, here is the complete list,
number 67 is green
local animetextEffect = 67
COLOR_BLACK = 0
COLOR_BLUE = 5
COLOR_BROWN = 120
COLOR_CADETBLUE = 100
COLOR_CORAL = 200
COLOR_CRIMSON = 188
COLOR_CYAN = 35
COLOR_DARKBLUE = 3
COLOR_DARKBROWN = 78
COLOR_DARKCYAN = 21
COLOR_DARKGOLD = 163
COLOR_DARKGREEN = 12
COLOR_DARKKHAKI = 171
COLOR_DARKMAGENTA = 75
COLOR_DARKOLIVEGREEN = 91
COLOR_DARKORANGE = 156
COLOR_DARKORCHID = 118
COLOR_DARKPINK = 152
COLOR_DARKPURPLE = 112
COLOR_DARKRED = 108
COLOR_DARKSEAGREEN = 135
COLOR_DARKSLATEBLUE = 87
COLOR_DARKSLATEGREY = 50
COLOR_DARKVIOLET = 113
COLOR_DEEPPINK = 189
COLOR_DEEPSKYBLUE = 29
COLOR_DODGERBLUE = 59
COLOR_FIREBRICK = 151
COLOR_FORESTGREEN = 55
COLOR_FUCHSIA = 185
COLOR_GOLD = 205
COLOR_GREY = 129
COLOR_GREEN = 18
COLOR_HOTPINK = 202
COLOR_KHAKI = 213
COLOR_LAWNGREEN = 138
COLOR_LIGHTAQUA = 64
COLOR_LIGHTBLUE = 89
COLOR_LIGHTGREEN = 66
COLOR_LIGHTORANGE = 204
COLOR_LIGHTSLATEGREY = 129
COLOR_LIGHTSTEELBLUE = 173
COLOR_LIME = 30
COLOR_LIMEGREEN = 67
COLOR_MEDIUMAQUAMARINE = 106
COLOR_MEDIUMORCHID = 161
COLOR_MEDIUMSEAGREEN = 99
COLOR_MEDIUMSLATEBLUE = 131
COLOR_MEDIUMSPRINGGREEN = 34
COLOR_MEDIUMVIOLET = 153
COLOR_MIDNIGHTBLUE = 45
COLOR_OLIVE = 126
COLOR_ORANGE = 198
COLOR_ORANGERED = 192
COLOR_ORCHID = 203
COLOR_PALEGREEN = 141
COLOR_PALEPINK = 208
COLOR_PINK = 190
COLOR_PURPLE = 154
COLOR_RED = 180
COLOR_ROSYBROWN = 165
COLOR_ROYALBLUE = 95
COLOR_SADDLEBROWN = 121
COLOR_SALMON = 201
COLOR_SANDYBROWN = 206
COLOR_SEAGREEN = 56
COLOR_SIENNA = 157
COLOR_SILVER = 172
COLOR_SKYBLUE = 21
COLOR_SLATEBLUE = 125
COLOR_SLATEGREY = 129
COLOR_SPRINGGREEN = 33
COLOR_STEELBLUE = 94
COLOR_TAN = 207
COLOR_TEAL = 143
COLOR_THISTLE = 209
COLOR_TOMATO = 194
COLOR_TURQUOISE = 107
COLOR_VIOLET = 119
COLOR_WHITE = 215
COLOR_YELLOW = 210
COLOR_YELLOWGREEN = 175
COLOR_NONE = 255
 
Last edited:
Man, OTClient is really far superior to CipSoft's default Tibia client. It offers incredible performance and supports many lyrics and other benefits. Unlike CipSoft's client, which is a big plus. I was recently able to find a script that only works in OTClient. I recommend you give it a try and see for yourself the wonders of OTClient.
Post automatically merged:

@Mateus Robeerto
You're a hero. I dont even understand what he asks

PS.: no offense
yeah, I already sent about 7-8 scripts it's working fine without errors, I'm not even going to do it anymore lol, I hope he uses otclient better than cip!
 
Last edited:
Show error:

Lua:
[12/06/2023 08:03:45] Gorgoth has logged in.

[12/06/2023 08:03:46] [Error - Action Interface]
[12/06/2023 08:03:46] In a timer event called from:
[12/06/2023 08:03:46] data/actions/scripts/access.lua:onUse
[12/06/2023 08:03:46] Description:
[12/06/2023 08:03:46] (luaGetCreatureName) Creature not found

[12/06/2023 08:03:46] [Error - Action Interface]
[12/06/2023 08:03:46] In a timer event called from:
[12/06/2023 08:03:46] data/actions/scripts/access.lua:onUse
[12/06/2023 08:03:46] Description:
[12/06/2023 08:03:47] data/actions/scripts/access.lua:13: attempt to index a boolean value
[12/06/2023 08:03:47] stack traceback:
[12/06/2023 08:03:47]     data/actions/scripts/access.lua:13: in function <data/actions/scripts/access.lua:10>
[12/06/2023 08:11:52] Gorgoth has logged out.
 

Similar threads

Replies
0
Views
385
Back
Top