TFS 0.X Exausted SSA/Might Ring

Discussion in 'Support' started by eyez, Sep 9, 2018.

  1. eyez

    eyez Member

    Joined:
    Oct 11, 2016
    Messages:
    69
    Likes Received:
    3
    Best Answers:
    0
    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 (Text):
    1.  
    2.     <!-- onequip_exausted_pvp -->
    3.     <movevent type="Equip" itemid="2197" slot="necklace" event="script" value="onequip_exausted_pvp/ssa_exhaust.lua"/>
    4.     <movevent type="DeEquip" itemid="2197" slot="necklace" event="script" value="onequip_exausted_pvp/ssa_exhaust.lua"/>
    5.     <movevent type="Equip" itemid="2164" slot="ring" event="script" value="onequip_exausted_pvp/mightring_exhaust.lua"/>
    6.     <movevent type="DeEquip" itemid="2164" slot="ring" event="script" value="onequip_exausted_pvp/mightring_exhaust.lua"/>
    7.  
    SSA
    Code (Text):
    1.  
    2. local storage = 9500
    3. local fixStorage = 8000
    4. local time = 4
    5. function onEquip(cid, item, slot, boolean)
    6.     if getPlayerStorageValue(cid, fixStorage) == 1 then
    7.         doPlayerSetStorageValue(cid, fixStorage, -1)
    8.         return callFunction(cid, item.uid, slot, boolean)
    9.     end
    10.     if getPlayerStorageValue(cid, storage) >= os.time() then
    11.         print("exhausted")
    12.         return false
    13.     end
    14.     doPlayerSetStorageValue(cid, storage, os.time() + time)
    15.     doPlayerSetStorageValue(cid, fixStorage, 1)
    16.     print("exhaustion set for 5 seconds")
    17.     return true
    18. end
    19. function onDeEquip(cid, item, slot, boolean)
    20.     return callFunction(cid, item.uid, slot, boolean)
    21. end
    22.  
    mightring
    Code (Text):
    1.  
    2. local storage = 9501
    3. local fixStorage = 8001
    4. local time = 4
    5. function onEquip(cid, item, slot, boolean)
    6.     if getPlayerStorageValue(cid, fixStorage) == 1 then
    7.         doPlayerSetStorageValue(cid, fixStorage, -1)
    8.         return callFunction(cid, item.uid, slot, boolean)
    9.     end
    10.     if getPlayerStorageValue(cid, storage) >= os.time() then
    11.         print("exhausted")
    12.         return false
    13.     end
    14.     doPlayerSetStorageValue(cid, storage, os.time() + time)
    15.     doPlayerSetStorageValue(cid, fixStorage, 1)
    16.     print("exhaustion set for 5 seconds")
    17.     return true
    18. end
    19. function onDeEquip(cid, item, slot, boolean)
    20.     return callFunction(cid, item.uid, slot, boolean)
    21. end
    22.  
     
  2. eyez

    eyez Member

    Joined:
    Oct 11, 2016
    Messages:
    69
    Likes Received:
    3
    Best Answers:
    0
    bump
     
  3. JDB

    JDB OtLand Veteran

    Joined:
    Jun 1, 2009
    Messages:
    4,134
    Likes Received:
    111
    Best Answers:
    2
    You should use the exhaustion function:
    Code (Lua):
    1. local exhaust = 3 --seconds
    2. local eStorage = 55510
    3. function onEquip(cid, item, slot)
    4.     if exhaustion.check(cid, eStorage) then
    5.         doPlayerSendCancel(cid, "You are exhausted.")
    6.         return false
    7.     end
    8.  
    9.     exhaustion.set(cid, eStorage, exhaust)
    10.     return true
    11. end
     
    Last edited: Sep 15, 2018
    eyez likes this.
  4. eyez

    eyez Member

    Joined:
    Oct 11, 2016
    Messages:
    69
    Likes Received:
    3
    Best Answers:
    0
    With this script it's showing the exausted message, removing on damage, but it's not blocking to equip when you are exausted
     
  5. eyez

    eyez Member

    Joined:
    Oct 11, 2016
    Messages:
    69
    Likes Received:
    3
    Best Answers:
    0
    bump
     
  6. eyez

    eyez Member

    Joined:
    Oct 11, 2016
    Messages:
    69
    Likes Received:
    3
    Best Answers:
    0
    bump
     
  7. eyez

    eyez Member

    Joined:
    Oct 11, 2016
    Messages:
    69
    Likes Received:
    3
    Best Answers:
    0
    bump
     
  8. eyez

    eyez Member

    Joined:
    Oct 11, 2016
    Messages:
    69
    Likes Received:
    3
    Best Answers:
    0
    bump
     
  9. eyez

    eyez Member

    Joined:
    Oct 11, 2016
    Messages:
    69
    Likes Received:
    3
    Best Answers:
    0
    bump
     
  10. jestem pro

    jestem pro That is the question

    Joined:
    Apr 20, 2013
    Messages:
    535
    Likes Received:
    58
    Best Answers:
    9
    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.
     
    eyez likes this.
  11. eyez

    eyez Member

    Joined:
    Oct 11, 2016
    Messages:
    69
    Likes Received:
    3
    Best Answers:
    0

    how? where?
    Fir3element/3777
     
  12. eyez

    eyez Member

    Joined:
    Oct 11, 2016
    Messages:
    69
    Likes Received:
    3
    Best Answers:
    0
    bump
     
  13. eyez

    eyez Member

    Joined:
    Oct 11, 2016
    Messages:
    69
    Likes Received:
    3
    Best Answers:
    0
    bump
     
  14. DukeeH

    DukeeH Active Member

    Joined:
    Dec 6, 2010
    Messages:
    525
    Likes Received:
    36
    Best Answers:
    3
    [Creatureevent] onMoveItem(cid, item, count, toContainer, fromContainer, ...)
    @eyez

    add this function to sources.

    Use this (creaturescripts.xml):
    Code (Text):
    1.     <event type="moveitem" name="MoveItem" event="script" value="ringamulet.lua"/>
    creaturescripts/ringamulet.xml:
    Code (Text):
    1.  
    2. local storage = 61894
    3. local exhause_time = 2500 -- in milli seconds
    4.  
    5. local function resetStorage(cid)
    6. if isPlayer(cid) then
    7. setPlayerStorageValue(cid, storage, 0)
    8. end
    9. end
    10.  
    11. local function doExhaust(cid)
    12. -- exhaust divided by 1000 can be 0 (500 / 1000 = 0), but in onMoveItem(..) we check if time is >= os.time()
    13. setPlayerStorageValue(cid,storage,os.time()+(exhause_time / 1000))
    14. -- so if 'event' does not execute, it won't be a problem (just block for 1 second [not 0.5 sec] IF you relog)
    15. addEvent(resetStorage, exhause_time, cid)
    16. end
    17.  
    18. function onMoveItem(cid, item, count, toContainer, fromContainer, fromPos, toPos)
    19.     if toPos.y == 2 or toPos.y == 9 then
    20.         if getPlayerStorageValue(cid,storage) >= os.time() then
    21.         doPlayerSendCancel(cid, "You're equip exhausted.")
    22.         return false
    23.         end
    24.     doExhaust(cid)
    25.     end
    26. return true
    27. end
    not made by me, I have it from some years, hope it works.
     
    eyez likes this.
  15. eyez

    eyez Member

    Joined:
    Oct 11, 2016
    Messages:
    69
    Likes Received:
    3
    Best Answers:
    0

    My server already has a moveitem function, so i tried to do like in my moveitem function:
    Code (Text):
    1.  
    2. local storage = 61894
    3. local exhause_time = 5500 -- in milli seconds
    4. local function resetStorage(cid)
    5.    if isPlayer(cid) then
    6.        setPlayerStorageValue(cid, storage, 0)
    7.    end
    8. end
    9. local function doExhaust(cid)
    10.    -- exhaust divided by 1000 can be 0 (500 / 1000 = 0), but in onMoveItem(..) we check if time is >= os.time()
    11.    setPlayerStorageValue(cid,storage,os.time()+(exhause_time / 1000))
    12.    -- so if 'event' does not execute, it won't be a problem (just block for 1 second [not 0.5 sec] IF you relog)
    13.    addEvent(resetStorage, exhause_time, cid)
    14. end
    15.  
    16. function onMoveItem(moveItem, frompos, position, cid)
    17.     if position.y == 2 or position.y == 9 then
    18.         if getPlayerStorageValue(cid,storage) >= os.time() then
    19.            doPlayerSendCancel(cid, "You're equip exhausted.")
    20.            return false
    21.         end
    22.        doExhaust(cid)
    23.     end
    24. return true
    25. end
    26.  
    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
     
  16. eyez

    eyez Member

    Joined:
    Oct 11, 2016
    Messages:
    69
    Likes Received:
    3
    Best Answers:
    0
    bump
     
  17. ClassicTiba

    ClassicTiba Classictibia.net (Low Rate Real Map 7.72)

    Joined:
    Oct 6, 2018
    Messages:
    58
    Likes Received:
    22
    Best Answers:
    0
    what tfs are you using ?
     
    eyez likes this.
  18. eyez

    eyez Member

    Joined:
    Oct 11, 2016
    Messages:
    69
    Likes Received:
    3
    Best Answers:
    0
  19. eyez

    eyez Member

    Joined:
    Oct 11, 2016
    Messages:
    69
    Likes Received:
    3
    Best Answers:
    0
    bumop
     

Share This Page

Loading...