• 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 [OTBR 1.x] SSA exhaust please

adrenysny

Member
Joined
Feb 17, 2021
Messages
140
Reaction score
14
hello, can someone help me put exhausted the ssa and might ring?
I already tested in /data/events/scripts/player.lua and it doesn't work


Lua:
    -- SSA exhaust
    local exhaust = { }
    if toPosition.x == CONTAINER_POSITION and toPosition.y == CONST_SLOT_NECKLACE
    and item:getId() == ITEM_STONE_SKIN_AMULET then
        local pid = self:getId()
        if exhaust[pid] then
            self:sendCancelMessage(RETURNVALUE_YOUAREEXHAUSTED)
            return false
        else
            exhaust[pid] = true
            addEvent(function() exhaust[pid] = false end, 2000, pid)
            return true
        end
    end
 
That won't work.
You have to set a storage value for the player, not just add the cid / pid to a table since that will be reset everytime the script is loaded (if it's a local variable that exhaust is)

The way to resolve this is to ex add a storage value with os.time() + time and then compare if that storage value is below os.time() before using the item.
 
Here is an example of what @WibbenZ says
Lua:
-- SSA exhaust
if toPosition.x == CONTAINER_POSITION and toPosition.y == CONST_SLOT_NECKLACE and item:getId() == ITEM_STONE_SKIN_AMULET then
    if self:getStorageValue(10000) > os.time() then
        self:sendCancelMessage(RETURNVALUE_YOUAREEXHAUSTED)
        return false
    else
        self:setStorageValue(10000, os.time() +2)
    end
end

btw, I'm not returning true when we set the cooling time, because I don't know if after this part of the script comes some other checks that should be verified, in theory this code is 99% perfect
 
Last edited:
Here is an example of what @WibbenZ says
Lua:
-- SSA exhaust
if toPosition.x == CONTAINER_POSITION and toPosition.y == CONST_SLOT_NECKLACE and item:getId() == ITEM_STONE_SKIN_AMULET then
    if self:getStorageValue(10000) > os.time() then
        self:sendCancelMessage(RETURNVALUE_YOUAREEXHAUSTED)
        return false
    else
        self:setStorageValue(10000, os.time() +2000)
    end
end
For this scripts to work, would you have to add a storage to the player that is forever?
 
other example:
Lua:
local stoneSkinAmuletExhausted = {}

-- SSA exhaust
if toPosition.x == CONTAINER_POSITION and toPosition.y == CONST_SLOT_NECKLACE and item:getId() == ITEM_STONE_SKIN_AMULET then
    local playerGuid = self:getGuid()
    if stoneSkinAmuletExhausted[playerGuid] and stoneSkinAmuletExhausted[playerGuid] > os.time() then
        self:sendCancelMessage(RETURNVALUE_YOUAREEXHAUSTED)
        return false
    else
        stoneSkinAmuletExhausted[playerGuid] = os.time() +2
    end
end

this part must be above and outside the onMoveItem event
local stoneSkinAmuletExhausted = {}
that:
1618104987408.png
 
Last edited:
other example:
Lua:
local stoneSkinAmuletExhausted = {}

-- SSA exhaust
if toPosition.x == CONTAINER_POSITION and toPosition.y == CONST_SLOT_NECKLACE and item:getId() == ITEM_STONE_SKIN_AMULET then
    local playerGuid = self:getGuid()
    if not stoneSkinAmuletExhausted[playerGuid] or stoneSkinAmuletExhausted[playerGuid] > os.time() then
        self:sendCancelMessage(RETURNVALUE_YOUAREEXHAUSTED)
        return false
    else
        stoneSkinAmuletExhausted[playerGuid] = os.time() +2000
    end
end

this part must be above and outside the onMoveItem event
local stoneSkinAmuletExhausted = {}
that:
View attachment 57548
no work :s
 
Sorry, I was wrong, here it is:

Update!
 
other example:
Lua:
local stoneSkinAmuletExhausted = {}

-- SSA exhaust
if toPosition.x == CONTAINER_POSITION and toPosition.y == CONST_SLOT_NECKLACE and item:getId() == ITEM_STONE_SKIN_AMULET then
    local playerGuid = self:getGuid()
    if stoneSkinAmuletExhausted[playerGuid] and stoneSkinAmuletExhausted[playerGuid] > os.time() then
        self:sendCancelMessage(RETURNVALUE_YOUAREEXHAUSTED)
        return false
    else
        stoneSkinAmuletExhausted[playerGuid] = os.time() +2
    end
end

this part must be above and outside the onMoveItem event
local stoneSkinAmuletExhausted = {}
that:
View attachment 57548
no work :s
 
Back
Top