• 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 Exhaust on wearing item

okurde

New Member
Joined
Jan 28, 2009
Messages
134
Reaction score
1
Hello, is there any script that allow putting on yourself (wearing) item for example one time per 2 seconds?

Thanks in advance
 
You can add a lua script to the item in movements, use an exhaust condition that lasts for 2 seconds, if the player has the condition, let it return false, if it returns false people can't equip the item.
 
You can add a lua script to the item in movements, use an exhaust condition that lasts for 2 seconds, if the player has the condition, let it return false, if it returns false people can't equip the item.
Sounds great but how to do it? :p
 
Sounds great but how to do it? :p
-- NOT TESTED
Add to movements :
Code:
<movevent event="Equip" itemid="<ID>" slot="feet" script="exaustitem.lua"/>
<movevent event="DeEquip" itemid="<ID>" slot="feet" script="exaustitem.lua"/>

And in movements/scripts/ create exaustitem.lua
Add in exaustitem.lua
Code:
local storage = 23006
local exausttime = 2

function onEquip(cid, item, slot)
    if not(exhaustion.check(cid, storage)) then
        exhaustion.set(cid, storage, exausttime)
        return true
    else
        return false
    end
end

function onDeEquip(cid, item, slot)
    if not(exhaustion.check(cid, storage)) then
        exhaustion.set(cid, storage, exausttime)
        return true
    else
        return false
    end
end
 
Hmm, I used this code and the result is: when I put item in right place then nothing happens, then I try again and I am exhausted, hmm thats weird
So i made breakpoints
Code:
local storage = 23006
local exausttime = 5

function onEquip(cid, item, slot)
    if not(exhaustion.check(cid, storage)) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "I am giving you an exhaust...")
        exhaustion.set(cid, storage, exausttime)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "I gave you exhaust, the next line should put item in right place.")
        return true
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are exhausted, please wait.")
        return false
    end
end

function onDeEquip(cid, item, slot)
    if not(exhaustion.check(cid, storage)) then
        exhaustion.set(cid, storage, exausttime)
        return true
    else
        return false
    end
end
and when I try put item then I see:
I am giving you an exhaust...
I gave you exhaust, the next line should put item in right place.
You are exhausted, please wait.

and nothing happens, item is not in right place.
I do not understand whats wrong, code looks good. But why code doesnt finish after "return true", it looks that code starts again after it, but why? There is no any loop, even though after "return" code should finish.. Does anyone know whats wrong?
 
Hmm, I used this code and the result is: when I put item in right place then nothing happens, then I try again and I am exhausted, hmm thats weird
So i made breakpoints
Code:
local storage = 23006
local exausttime = 5

function onEquip(cid, item, slot)
    if not(exhaustion.check(cid, storage)) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "I am giving you an exhaust...")
        exhaustion.set(cid, storage, exausttime)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "I gave you exhaust, the next line should put item in right place.")
        return true
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are exhausted, please wait.")
        return false
    end
end

function onDeEquip(cid, item, slot)
    if not(exhaustion.check(cid, storage)) then
        exhaustion.set(cid, storage, exausttime)
        return true
    else
        return false
    end
end
and when I try put item then I see:
I am giving you an exhaust...
I gave you exhaust, the next line should put item in right place.
You are exhausted, please wait.

and nothing happens, item is not in right place.
I do not understand whats wrong, code looks good. But why code doesnt finish after "return true", it looks that code starts again after it, but why? There is no any loop, even though after "return" code should finish.. Does anyone know whats wrong?

Try using this exhausted:
Code:
local gab = {
exhausted = 2.7, -- Time you are exhausted. by second
storage = 91355 -- Storage used for "exhaust."
}
----------------------------------------
setPlayerStorageValue(cid, gab.storage, os.time() + gab.exhausted)
 
Try using this exhausted:
Code:
local gab = {
exhausted = 2.7, -- Time you are exhausted. by second
storage = 91355 -- Storage used for "exhaust."
}
----------------------------------------
setPlayerStorageValue(cid, gab.storage, os.time() + gab.exhausted)
it's the same. if you checked data/lib/core/exhaust.lua you will find it the same you provided.
 
Ok, I have:
Code:
local storage = 23006
local exhausttime = 5

function onEquip(cid, item, slot)
    if (exhaustion.check(cid, storage)) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are exhausted, please wait [onEquip].")
        return false
    else
        local itemx = getPlayerSlotItem(cid, 2).itemid
        if (itemx ~= item.itemid) then
            print(itemx)
            print(item.itemid)
            exhaustion.set(cid, storage, exhausttime)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have been exhausted [onEquip].")
            return true
        end
    end
end

function onDeEquip(cid, item, slot)
    if (exhaustion.check(cid, storage)) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are exhausted, please wait [onDeEquip].")
        return false
    else
        local itemx = getPlayerSlotItem(cid, 2).itemid
        if (itemx ~= item.itemid) then
            print(itemx)
            print(item.itemid)
            exhaustion.set(cid, storage, exhausttime)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have been exhausted [onDeEquip].")
            return true
        end           
    end
end

When I have item in slot "2" and I am trying to put from backpack the same item to slot "2" then:
You have been exhausted [onDeEquip].
You are exhausted, please wait [onEquip].
and both items are in backpack. It is wrong because script should prevent putting item in slot if there is already put the same item = one item should be in slot as it was and one item should stay in backpack as it was.

I tried to do it with getPlayerSlotItem(cid, 2).itemid and item.itemid, but there was no result so I printed it.
Alwyas getPlayerSlotItem(cid, 2).itemid prints value 0, doesn't matter whether there is any item or there is not... why? or is there any other way to solve it?
 
Last edited:
Back
Top