Ir para conteúdo

-=[TFS]=- 0.4 8.60 Preciso de um suporte quando de use no item ele somi e aparece contdown de 30 minutos de acesso a uma area donate

Featured Replies

Postado

da use no item player tem acesso area donate por 30 minutos depois ele é kickado o problema desse script é que ele não aparece contdown e não remove item do set ou na bp.

ACTION:

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

MOVEMENTS:

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

Editado por Muvukaa (veja o histórico de edições)

  • Muvukaa mudou o título para -=[TFS]=- 0.4 8.60 Preciso de um suporte quando de use no item ele somi e aparece contdown de 30 minutos de acesso a uma area donate

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 520.3k

Informação Importante

Confirmação de Termo