Sounds great but how to do it?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.
-- NOT TESTEDSounds great but how to do it?
<movevent event="Equip" itemid="<ID>" slot="feet" script="exaustitem.lua"/>
<movevent event="DeEquip" itemid="<ID>" slot="feet" script="exaustitem.lua"/>
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
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
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
and when I try put item then I see: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
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?
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.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)
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