TFS 0.X Exausted SSA/Might Ring

eyez

Member
Joined
Oct 11, 2016
Messages
91
Reaction score
4
I did found this script to add a exausted on SSA and Might Ring (to prevent bots rulles)
It's working, you cant equip the item before exausted finish

But SSA and Might Ring are not losing charges after u recive damage (after i added this script)

Code:
    <!-- onequip_exausted_pvp -->
    <movevent type="Equip" itemid="2197" slot="necklace" event="script" value="onequip_exausted_pvp/ssa_exhaust.lua"/>
    <movevent type="DeEquip" itemid="2197" slot="necklace" event="script" value="onequip_exausted_pvp/ssa_exhaust.lua"/>
    <movevent type="Equip" itemid="2164" slot="ring" event="script" value="onequip_exausted_pvp/mightring_exhaust.lua"/>
    <movevent type="DeEquip" itemid="2164" slot="ring" event="script" value="onequip_exausted_pvp/mightring_exhaust.lua"/>
SSA
Code:
local storage = 9500
local fixStorage = 8000
local time = 4
function onEquip(cid, item, slot, boolean)
    if getPlayerStorageValue(cid, fixStorage) == 1 then
        doPlayerSetStorageValue(cid, fixStorage, -1)
        return callFunction(cid, item.uid, slot, boolean)
    end
    if getPlayerStorageValue(cid, storage) >= os.time() then
        print("exhausted")
        return false
    end
    doPlayerSetStorageValue(cid, storage, os.time() + time)
    doPlayerSetStorageValue(cid, fixStorage, 1)
    print("exhaustion set for 5 seconds")
    return true
end
function onDeEquip(cid, item, slot, boolean)
    return callFunction(cid, item.uid, slot, boolean)
end
mightring
Code:
local storage = 9501
local fixStorage = 8001
local time = 4
function onEquip(cid, item, slot, boolean)
    if getPlayerStorageValue(cid, fixStorage) == 1 then
        doPlayerSetStorageValue(cid, fixStorage, -1)
        return callFunction(cid, item.uid, slot, boolean)
    end
    if getPlayerStorageValue(cid, storage) >= os.time() then
        print("exhausted")
        return false
    end
    doPlayerSetStorageValue(cid, storage, os.time() + time)
    doPlayerSetStorageValue(cid, fixStorage, 1)
    print("exhaustion set for 5 seconds")
    return true
end
function onDeEquip(cid, item, slot, boolean)
    return callFunction(cid, item.uid, slot, boolean)
end
 

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Reaction score
109
You should use the exhaustion function:
Lua:
local exhaust = 3 --seconds
local eStorage = 55510
function onEquip(cid, item, slot)
    if exhaustion.check(cid, eStorage) then
        doPlayerSendCancel(cid, "You are exhausted.")
        return false
    end
 
    exhaustion.set(cid, eStorage, exhaust)
    return true
end
 
Last edited:
OP
eyez

eyez

Member
Joined
Oct 11, 2016
Messages
91
Reaction score
4
You should use the exhaustion function:
Lua:
local exhaust = 3 --seconds
local eStorage = 55510
function onEquip(cid, item, slot)
    if exhaustion.check(cid, eStorage) then
        return doPlayerSendCancel(cid, "You are exhausted."), false
    end
 
    exhaustion.set(cid, eStorage, exhaust)
    return true
end
With this script it's showing the exausted message, removing on damage, but it's not blocking to equip when you are exausted
 

jestem pro

That is the question
Joined
Apr 20, 2013
Messages
564
Reaction score
65
coz it rather needs to be done by sources not lua
now you can pick up the item but if you're exhausted, cannot use.
 

DukeeH

Intermediate OT User
Joined
Dec 6, 2010
Messages
527
Reaction score
36
[Creatureevent] onMoveItem(cid, item, count, toContainer, fromContainer, ...)
@eyez

add this function to sources.

Use this (creaturescripts.xml):
Code:
    <event type="moveitem" name="MoveItem" event="script" value="ringamulet.lua"/>
creaturescripts/ringamulet.xml:
Code:
local storage = 61894
local exhause_time = 2500 -- in milli seconds

local function resetStorage(cid)
if isPlayer(cid) then
setPlayerStorageValue(cid, storage, 0)
end
end

local function doExhaust(cid)
-- exhaust divided by 1000 can be 0 (500 / 1000 = 0), but in onMoveItem(..) we check if time is >= os.time()
setPlayerStorageValue(cid,storage,os.time()+(exhause_time / 1000))
-- so if 'event' does not execute, it won't be a problem (just block for 1 second [not 0.5 sec] IF you relog)
addEvent(resetStorage, exhause_time, cid)
end

function onMoveItem(cid, item, count, toContainer, fromContainer, fromPos, toPos)
    if toPos.y == 2 or toPos.y == 9 then
        if getPlayerStorageValue(cid,storage) >= os.time() then
        doPlayerSendCancel(cid, "You're equip exhausted.")
        return false
        end
    doExhaust(cid)
    end
return true
end
not made by me, I have it from some years, hope it works.
 
OP
eyez

eyez

Member
Joined
Oct 11, 2016
Messages
91
Reaction score
4
[Creatureevent] onMoveItem(cid, item, count, toContainer, fromContainer, ...)
@eyez

add this function to sources.

Use this (creaturescripts.xml):
Code:
    <event type="moveitem" name="MoveItem" event="script" value="ringamulet.lua"/>
creaturescripts/ringamulet.xml:
Code:
local storage = 61894
local exhause_time = 2500 -- in milli seconds

local function resetStorage(cid)
if isPlayer(cid) then
setPlayerStorageValue(cid, storage, 0)
end
end

local function doExhaust(cid)
-- exhaust divided by 1000 can be 0 (500 / 1000 = 0), but in onMoveItem(..) we check if time is >= os.time()
setPlayerStorageValue(cid,storage,os.time()+(exhause_time / 1000))
-- so if 'event' does not execute, it won't be a problem (just block for 1 second [not 0.5 sec] IF you relog)
addEvent(resetStorage, exhause_time, cid)
end

function onMoveItem(cid, item, count, toContainer, fromContainer, fromPos, toPos)
    if toPos.y == 2 or toPos.y == 9 then
        if getPlayerStorageValue(cid,storage) >= os.time() then
        doPlayerSendCancel(cid, "You're equip exhausted.")
        return false
        end
    doExhaust(cid)
    end
return true
end
not made by me, I have it from some years, hope it works.

My server already has a moveitem function, so i tried to do like in my moveitem function:
Code:
local storage = 61894
local exhause_time = 5500 -- in milli seconds
local function resetStorage(cid)
   if isPlayer(cid) then
       setPlayerStorageValue(cid, storage, 0)
   end
end
local function doExhaust(cid)
   -- exhaust divided by 1000 can be 0 (500 / 1000 = 0), but in onMoveItem(..) we check if time is >= os.time()
   setPlayerStorageValue(cid,storage,os.time()+(exhause_time / 1000))
   -- so if 'event' does not execute, it won't be a problem (just block for 1 second [not 0.5 sec] IF you relog)
   addEvent(resetStorage, exhause_time, cid)
end

function onMoveItem(moveItem, frompos, position, cid)
    if position.y == 2 or position.y == 9 then
        if getPlayerStorageValue(cid,storage) >= os.time() then
           doPlayerSendCancel(cid, "You're equip exhausted.")
           return false
        end
       doExhaust(cid)
    end
return true
end
It's detecting the equip item, everytime when i equip a ring/amulet, it shows You are exausted
But it's not blocking to equip


my creatureevent.cpp:
hastebin

creatureevent.h:
hastebin
 
Top