• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua -=[TFS]=- 0.4 8.60 Script Use Item x | for time use item time for acess area

samuel157

/root
Joined
Mar 19, 2010
Messages
447
Solutions
3
Reaction score
49
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
 
Solution
try this script

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 cooldownTime = 30 * 60 -- Tempo de cooldown em segundos (30 minutos)
local timeInterval = 60 -- Intervalo de verificação de tempo em segundos (exemplo: 1 minuto)

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
        local minutes = math.floor(remainingTime /...
I added cooldown and countdown, test there I hope it works


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 cooldownTime = 30 * 60 -- Tempo de cooldown em segundos (30 minutos)

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
        local minutes = math.floor(remainingTime / 60)
        local seconds = remainingTime % 60

        doPlayerSendCancel(cid, "Aguarde mais " .. minutes .. " minutos e " .. seconds .. " segundos antes de usar novamente.")
        return true
    end

    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 expirationTime = currentTime + (72 * 60 * 60) -- Convertendo 72 horas para segundos

    setPlayerStorageValue(cid, storageValue, expirationTime)
    setPlayerStorageValue(cid, "lastUsageTime", currentTime)
    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 lastTimeCheck = getPlayerStorageValue(cid, "lastTimeCheck")
    local timeDifference = currentTime - 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
 
try this script

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 cooldownTime = 30 * 60 -- Tempo de cooldown em segundos (30 minutos)
local timeInterval = 60 -- Intervalo de verificação de tempo em segundos (exemplo: 1 minuto)

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
        local minutes = math.floor(remainingTime / 60)
        local seconds = remainingTime % 60

        doPlayerSendCancel(cid, "Aguarde mais " .. minutes .. " minutos e " .. seconds .. " segundos antes de usar novamente.")
        return true
    end

    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 expirationTime = currentTime + (72 * 60 * 60) -- Convertendo 72 horas para segundos

    setPlayerStorageValue(cid, storageValue, expirationTime)
    setPlayerStorageValue(cid, "lastUsageTime", currentTime)
    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 lastTimeCheck = getPlayerStorageValue(cid, "lastTimeCheck")
    local timeDifference = currentTime - lastTimeCheck

    if timeDifference >= timeInterval then
        local timeRemaining = expirationTime - currentTime
        if timeRemaining > 0 then
            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)
        end

        setPlayerStorageValue(cid, "lastTimeCheck", currentTime)
    end

    return true
end
 
Solution
If you want to change the time, just modify it.
local expirationTime = currentTime + (30 * 60) -- Convertendo 30 minutos para segundos

Lua:
local storageValue = 13741
local itemID = 8981 -- Item utilizado para conceder o acesso de 30 minutos
local teleportPosition = {x = 154, y = 51, z = 7} -- Posição de teleporte quando o tempo acabar
local cooldownTime = 30 * 60 -- Tempo de cooldown em segundos (30 minutos)
local timeInterval = 60 -- Intervalo de verificação de tempo em segundos (exemplo: 1 minuto)

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
        local minutes = math.floor(remainingTime / 60)
        local seconds = remainingTime % 60

        doPlayerSendCancel(cid, "Aguarde mais " .. minutes .. " minutos e " .. seconds .. " segundos antes de usar novamente.")
        return true
    end

    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 expirationTime = currentTime + (30 * 60) -- Convertendo 30 minutos para segundos

    setPlayerStorageValue(cid, storageValue, expirationTime)
    setPlayerStorageValue(cid, "lastUsageTime", currentTime)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você ganhou acesso a essa funcionalidade por 30 minutos.")

    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 lastTimeCheck = getPlayerStorageValue(cid, "lastTimeCheck")
    local timeDifference = currentTime - lastTimeCheck

    if timeDifference >= timeInterval then
        local timeRemaining = expirationTime - currentTime
        if timeRemaining > 0 then
            local minutes = math.floor(timeRemaining / 60)
            local seconds = timeRemaining % 60

            local timeString = string.format("%02d:%02d", minutes, seconds)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Tempo restante: " .. timeString)
        end

        setPlayerStorageValue(cid, "lastTimeCheck", currentTime)
    end

    return true
end
 

Similar threads

Back
Top