Advertisement
Guest User

Untitled

a guest
Jun 12th, 2023
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. local storageValue = 13741
  2. local itemID = 8981
  3. local teleportPosition = {x = 154, y = 51, z = 7}
  4. local cooldownTime = 30 * 60
  5. local animetextEffect = 67
  6. local animetextEffectInterval = 5
  7.  
  8. local function sendBuffActiveText(cid, remainingTime)
  9. local minutes = math.floor(remainingTime / 60)
  10. local seconds = remainingTime % 60
  11.  
  12. doSendAnimatedText(getPlayerPosition(cid), minutes .. "m " .. seconds .. "s", animetextEffect)
  13.  
  14. if remainingTime > 0 then
  15. addEvent(sendBuffActiveText, animetextEffectInterval * 1000, cid, remainingTime - animetextEffectInterval)
  16. end
  17. end
  18.  
  19. local function sendCountdownText(cid, remainingTime)
  20. local minutes = math.floor(remainingTime / 60)
  21. local seconds = remainingTime % 60
  22.  
  23. doSendAnimatedText(getPlayerPosition(cid), "Aguarde mais " .. minutes .. " minutos e " .. seconds .. " segundos", countdownTextEffect)
  24. end
  25.  
  26. local function removeAccess(cid)
  27. if isPlayer(cid) then
  28. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Seu tempo de acesso expirou.")
  29. doTeleportThing(cid, teleportPosition)
  30. setPlayerStorageValue(cid, storageValue, -1)
  31. end
  32. end
  33.  
  34. function onUse(cid, item, frompos, item2, topos)
  35. local lastUsageTime = getPlayerStorageValue(cid, "lastUsageTime")
  36. local currentTime = os.time()
  37.  
  38. if lastUsageTime ~= -1 and currentTime < lastUsageTime + cooldownTime then
  39. local remainingTime = (lastUsageTime + cooldownTime) - currentTime
  40. sendCountdownText(cid, remainingTime)
  41. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Aguarde mais " .. math.floor(remainingTime / 60) .. " minutos e " .. remainingTime % 60 .. " segundos antes de usar novamente.")
  42. return true
  43. end
  44.  
  45. if getPlayerStorageValue(cid, storageValue) ~= -1 then
  46. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você já tem acesso a essa funcionalidade.")
  47. return true
  48. end
  49.  
  50. local hasUnlimitedCharges = getPlayerStorageValue(cid, "hasUnlimitedCharges") == 1
  51.  
  52. if not hasUnlimitedCharges and not doPlayerRemoveItem(cid, itemID, 1) then
  53. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você precisa ter o item necessário para usar essa funcionalidade.")
  54. return true
  55. end
  56.  
  57. local expirationTime = currentTime + (30 * 60)
  58.  
  59. setPlayerStorageValue(cid, storageValue, expirationTime)
  60. setPlayerStorageValue(cid, "lastUsageTime", currentTime)
  61. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você ganhou acesso a essa funcionalidade por 30 minutos.")
  62.  
  63. sendCountdownText(cid, 30 * 60)
  64.  
  65. addEvent(removeAccess, cooldownTime * 1000, cid)
  66.  
  67. addEvent(function()
  68. handleLogin(cid)
  69. end, 1000)
  70.  
  71. temporaryStorageIncrease(cid, storageValue, 30 * 60, cooldownTime * 1000)
  72.  
  73. sendBuffActiveText(cid, 30 * 60) -- Adicionado para exibir o texto de contagem regressiva ativa
  74.  
  75. return true
  76. end
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement