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

TFS 0.X Exausted SSA/Might Ring

eyez

Member
Joined
Oct 11, 2016
Messages
129
Reaction score
19
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
 
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:
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
 
[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.
 
[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
 
Back
Top