• 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!

RevScripts help with scripts, delay doesn't work

Winchester83

New Member
Joined
Oct 25, 2023
Messages
35
Reaction score
4
Good morning everyone, so, I had made a request about these scripts here on this forum, and someone even offended me, but somehow I managed to create one and the revive part is working, but the delay is not, could someone transform that ? in revscripts or just adjust the delay operation,



This is the script, only the delay time is working:

thank you all!

local configs = {
ring_id = 26544,
delay_time = 5*60*1000,
delay_storage = 10000
}

local conditions = {
CONDITION_POISON,
CONDITION_FIRE,
CONDITION_ENERGY,
CONDITION_LIFEDRAIN,
CONDITION_HASTE,
CONDITION_PARALYZE,
CONDITION_OUTFIT,
CONDITION_INVISIBLE,
CONDITION_LIGHT,
CONDITION_MANASHIELD,
CONDITION_INFIGHT,
CONDITION_DRUNK,
CONDITION_DROWN,
CONDITION_BLEED,
}

function onPrepareDeath(cid, killer)
local ring_slot = getPlayerSlotItem(cid,CONST_SLOT_RING).itemid

if isPlayer(cid) then
if(ring_slot == configs.ring_id and getPlayerStorageValue(cid, configs.delay_storage) <= os.time())then
if doPlayerRemoveItem(cid, ring_slot, 1) then
doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
doPlayerAddMana(cid, getPlayerMaxMana(cid))
doPlayerSendTextMessage(cid,25,"REVIVED.")
doSendMagicEffect(getCreaturePosition(cid), 249)
return false
end
end
end
return true
end
 
Solution
Try it this way and see if it works for you:

Lua:
local configs = {
    ring_id = 26544,
    delay_time = 5 * 60,
    delay_storage = 10000
}

function onPrepareDeath(cid, killer)
    local ring_slot = getPlayerSlotItem(cid, CONST_SLOT_RING).itemid

    if isPlayer(cid) and ring_slot == configs.ring_id then
        local lastUsedTime = getPlayerStorageValue(cid, configs.delay_storage)
        local currentTime = os.time()

        if lastUsedTime <= currentTime then
            if doPlayerRemoveItem(cid, ring_slot, 1) then
                doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
                doPlayerAddMana(cid, getPlayerMaxMana(cid))
                doPlayerSendTextMessage(cid, 25, "REVIVED.")...
Try it this way and see if it works for you:

Lua:
local configs = {
    ring_id = 26544,
    delay_time = 5 * 60,
    delay_storage = 10000
}

function onPrepareDeath(cid, killer)
    local ring_slot = getPlayerSlotItem(cid, CONST_SLOT_RING).itemid

    if isPlayer(cid) and ring_slot == configs.ring_id then
        local lastUsedTime = getPlayerStorageValue(cid, configs.delay_storage)
        local currentTime = os.time()

        if lastUsedTime <= currentTime then
            if doPlayerRemoveItem(cid, ring_slot, 1) then
                doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
                doPlayerAddMana(cid, getPlayerMaxMana(cid))
                doPlayerSendTextMessage(cid, 25, "REVIVED.")
                doSendMagicEffect(getCreaturePosition(cid), 249)
                setPlayerStorageValue(cid, configs.delay_storage, currentTime + configs.delay_time)
                return false
            end
        else
            local remainingTime = lastUsedTime - currentTime
            doPlayerSendTextMessage(cid, 25, "You must wait " .. remainingTime .. " seconds to use the ring again.")
        end
    end

    return true
end

Delay Check: When player dies, the script first checks whether the specific ring is in the ring slot and then checks whether the delay time has passed by comparing the stored value with the current time.

Reset Delay: If the ring is used, the script sets the storage value to the current time plus the delay time.

Delay Message: If the ring is still on cooldown, the script tells the player how much time is left until it can be used again.
 
Solution

Similar threads

Back
Top