samuel157
/root
- Joined
- Mar 19, 2010
- Messages
- 461
- Solutions
- 3
- Reaction score
- 59
- Location
- São Paulo, Brazil
- GitHub
- Samuel10M
LUA:
I need a very simple revscript even when the player gives use in the newspaper 8981 golden appears contdown 30 60 minutes and seconds and action/movements I already did I just need the script that works in the action in this case this script I need support who can help I appreciate this there is action storage floor that it will pass if you use it in the newspaper on the set or in the bp item sumi can only get it if you pull the lever I already did only this action that is embarrassing me movements I already needed only action with countdown of 30 minutes countdown
NEED SCRIPT ACTION ON FUNCTION CONTDOWN 30:60 59 01 29:59 58 AND BUG LOGOUT AHEAD OF TIME
Code:
<action itemid="8981" script="access.lua"/>
local storageValue = 13741
local itemID = 8981 -- Item utilizado para conceder o acesso de 72 horas
local teleportPosition = {x = 154, y = 51, z = 7} -- Posição de teleporte quando o tempo acabar
local timeInterval = 1 * 60 -- Intervalo de tempo em segundos (30 minutos)
function onUse(cid, item, frompos, item2, topos)
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 currentTime = os.time()
local accessTime = 72 * 60 * 60 -- Convertendo 72 horas para segundos
local expirationTime = currentTime + accessTime
setPlayerStorageValue(cid, storageValue, expirationTime)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você ganhou acesso a essa funcionalidade por 72 horas.")
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 timeDifference = currentTime - getPlayerStorageValue(cid, "lastTimeCheck")
if timeDifference >= timeInterval then
local timeRemaining = expirationTime - currentTime
local hours = math.floor(timeRemaining / 3600)
local minutes = math.floor((timeRemaining % 3600) / 60)
local seconds = timeRemaining % 60
local timeString = string.format("%02d:%02d:%02d", hours, minutes, seconds)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Tempo restante: " .. timeString)
setPlayerStorageValue(cid, "lastTimeCheck", currentTime)
end
return true
end