local config = {
p_time = 3600 -- Tempo em segundos para receber os pontos (1 hora)
}
function onSay(cid, words, param, channel)
local getP = getPoints(cid)
local lastTime = getCreatureStorage(cid, 1219)
local currentTime = os.time() -- Usa o tempo de jogo
local timeElapsed = currentTime - lastTime
local timeRemaining = config.p_time - timeElapsed
if timeRemaining < 0 then
timeRemaining = 0
end
local hours = math.floor(timeRemaining / 3600)
local minutes = math.floor((timeRemaining % 3600) / 60)
local seconds = timeRemaining % 60
doPlayerPopupFYI(cid, string.format("Você possui %d p-points!\nPróximo ponto em: %02d:%02d:%02d", getP, hours, minutes, seconds))
return true
end
local config = {
p_time = 3600, -- Tempo em segundos para receber os pontos (1 hora)
p_points = 1 -- Quantidade de pontos recebida a cada "p_time"
}
local GLOBAL_TIME_STORAGE = 1220 -- Define um storage global para o tempo de jogo
local function givePoints(cid, quant)
local currentTime = os.time() -- Usa o tempo de jogo
if currentTime - getCreatureStorage(cid, 1219) >= config.p_time then
doPlayerSendTextMessage(cid, 19, "Parabéns, você recebeu ".. config.p_points .." p-point. Agora você tem ".. config.p_points + getPoints(cid) .." p-points na sua conta. Seu tempo foi zerado, próximo p-points daqui 1 hora.")
doPlayerAddPoints(cid, quant)
doCreatureSetStorage(cid, 1219, currentTime)
end
return true
end
function onThink(interval)
local currentTime = os.time()
setGlobalStorageValue(GLOBAL_TIME_STORAGE, currentTime)
for i, v in pairs(getPlayersOnline()) do
if getCreatureStorage(v, 1219) > 0 then -- Verifica se o storage está inicializado
givePoints(v, config.p_points)
else
doCreatureSetStorage(v, 1219, currentTime) -- Inicializa o storage para novos personagens
end
end
return true
end