Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local storageValue = 13741
- local itemID = 8981
- local teleportPosition = {x = 154, y = 51, z = 7}
- local cooldownTime = 30 * 60
- local animetextEffect = 67
- local animetextEffectInterval = 5
- local function sendBuffActiveText(cid, remainingTime)
- local minutes = math.floor(remainingTime / 60)
- local seconds = remainingTime % 60
- doSendAnimatedText(getPlayerPosition(cid), minutes .. "m " .. seconds .. "s", animetextEffect)
- if remainingTime > 0 then
- addEvent(sendBuffActiveText, animetextEffectInterval * 1000, cid, remainingTime - animetextEffectInterval)
- end
- end
- local function sendCountdownText(cid, remainingTime)
- local minutes = math.floor(remainingTime / 60)
- local seconds = remainingTime % 60
- doSendAnimatedText(getPlayerPosition(cid), "Aguarde mais " .. minutes .. " minutos e " .. seconds .. " segundos", countdownTextEffect)
- end
- local function removeAccess(cid)
- if isPlayer(cid) then
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Seu tempo de acesso expirou.")
- doTeleportThing(cid, teleportPosition)
- setPlayerStorageValue(cid, storageValue, -1)
- end
- 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(removeAccess, cooldownTime * 1000, cid)
- addEvent(function()
- handleLogin(cid)
- end, 1000)
- temporaryStorageIncrease(cid, storageValue, 30 * 60, cooldownTime * 1000)
- sendBuffActiveText(cid, 30 * 60) -- Adicionado para exibir o texto de contagem regressiva ativa
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement