• 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
 
X 65535 = inventory area
Y 9 = ring slot
Y 2 = necklace

put in /lib/000-constant
Lua:
global_equip_exhaust = {}
Put in creaturescripts/scripts (and register in login.lua / creaturescripts.xml)
Lua:
local exhaust_timer = 2000 -- milliseconds

function onMoveItem(item, fromPosition, toPosition, cid)
    if toPosition.x == 65535 then
        if item.itemid == 2197 and toPosition.y == 2 or item.itemid == 2164 and toPosition.y == 9 then
            local cur_time = os.mtime()
            if global_equip_exhaust[cid] and global_equip_exhaust[cid] > cur_time then
                doPlayerSendCancel(cid, "You are exhausted. Try again in a few moments.")
                return false
            end
            global_equip_exhaust[cid] = cur_time + exhaust_timer
        end    
    end
    return true
end
 
X 65535 = inventory area
Y 9 = ring slot
Y 2 = necklace

put in /lib/000-constant
Lua:
global_equip_exhaust = {}
Put in creaturescripts/scripts (and register in login.lua / creaturescripts.xml)
Lua:
local exhaust_timer = 2000 -- milliseconds

function onMoveItem(item, fromPosition, toPosition, cid)
    if toPosition.x == 65535 then
        if item.itemid == 2197 and toPosition.y == 2 or item.itemid == 2164 and toPosition.y == 9 then
            local cur_time = os.mtime()
            if global_equip_exhaust[cid] and global_equip_exhaust[cid] > cur_time then
                doPlayerSendCancel(cid, "You are exhausted. Try again in a few moments.")
                return false
            end
            global_equip_exhaust[cid] = cur_time + exhaust_timer
        end   
    end
    return true
end

I've added it on the last line of 000-const

On login registerCreatureEvent(cid, "ssamightExausted")
Code:
<event type="moveitem" name="ssamightExausted" event="script" value="ringamulet.lua"/>

And on movemments:
Code:
    <movevent type="Equip" itemid="2197" slot="necklace" event="function" value="onEquipItem"/>
    <movevent type="DeEquip" itemid="2197" slot="necklace" event="function" value="onDeEquipItem"/>
    <movevent type="Equip" itemid="2164" slot="ring" event="function" value="onEquipItem"/>
    <movevent type="DeEquip" itemid="2164" slot="ring" event="function" value="onDeEquipItem"/>


But its not working, not even showing the exausted message

Did u know why?
 
I was thinking, after all this time, no one could do it to work, not even @Xikini
Is it impossible to do in lua?
I dont know how to change source code, it still clean like Fir3element/3777 (https://github.com/Fir3element/3777/tree/master/src)
But the a bad thing about 8.6 servers is: PvP = bot
This script would change a part os this...
And i saw a lot ppl search about it
I don't see a reason my code wouldn't work, unless the script isn't triggering at all.
add me to discord and I could teamviewer with you to test out a couple of things quick.
 
Open the movement.cpp file and search:
C++:
bool MoveEvent::executeEquip(Player* player, Item* item, slots_t slot, bool boolean)
Go to the line:
C++:
lua_pushboolean(L, boolean);
Next, add this line:
C++:
lua_pushboolean(L, equip ? EquipItem(this, player, item, slot, boolean) : DeEquipItem(this, player, item, slot, boolean));
Logo abaixo tem: bool result = m_interface->callFunction(4);
C++:
bool result = m_interface->callFunction(4);
Altere para:
C++:
bool result = m_interface->callFunction(5);

This solution is for you to be able to use a lua script without interfering with the default attributes that are given by items.xml, tell me if it worked and mark it as the best answer.
NOTE: Use the first script you posted if it was working.
 
Open the movement.cpp file and search:
C++:
bool MoveEvent::executeEquip(Player* player, Item* item, slots_t slot, bool boolean)
Go to the line:
C++:
lua_pushboolean(L, boolean);
Next, add this line:
C++:
lua_pushboolean(L, equip ? EquipItem(this, player, item, slot, boolean) : DeEquipItem(this, player, item, slot, boolean));
Logo abaixo tem: bool result = m_interface->callFunction(4);
C++:
bool result = m_interface->callFunction(4);
Altere para:
C++:
bool result = m_interface->callFunction(5);

This solution is for you to be able to use a lua script without interfering with the default attributes that are given by items.xml, tell me if it worked and mark it as the best answer.
NOTE: Use the first script you posted if it was working.

Like this? hastebin (https://hastebin.com/cowegohufo.php)

I'm getting some errors:
Code:
CC       = g++
movement.cpp: In member function ‘bool MoveEvent::executeEquip(Player*, Item*, slots_t, bool)’:
movement.cpp:1282:23: error: ‘equip’ was not declared in this scope
    lua_pushboolean(L, equip ? EquipItem(this, player, item, slot, boolean) : DeEquipItem(this, player, item, slot, boolean));
                       ^~~~~
Makefile:33: recipe for target 'movement.o' failed
make: *** [movement.o] Error 1
 
In movement.h search for:
C++:
executeEquip(Player* player, Item* item, slots_t slot, bool boolean);
Change for:
C++:
executeEquip(Player* player, Item* item, slots_t slot, bool boolean, bool equip);
search for:
C++:
fireEquip(Player* player, Item* item, slots_t slot, bool boolean);
Change for:
C++:
fireEquip(Player* player, Item* item, slots_t slot, bool boolean, bool equip);
E troque o arquivo movement.cpp para esse:
movement.cpp
 
In movement.h search for:
C++:
executeEquip(Player* player, Item* item, slots_t slot, bool boolean);
Change for:
C++:
executeEquip(Player* player, Item* item, slots_t slot, bool boolean, bool equip);
search for:
C++:
fireEquip(Player* player, Item* item, slots_t slot, bool boolean);
Change for:
C++:
fireEquip(Player* player, Item* item, slots_t slot, bool boolean, bool equip);
E troque o arquivo movement.cpp para esse:
movement.cpp

Your movement.cpp is empty
Could you just tell me what to do in my?

 

Using your movemment.cpp and using this scripts to control the exausted:

movemments.xml
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="function" value="onDeEquipItem"/>
    <movevent type="Equip" itemid="2164" slot="ring" event="script" value="onequip_exausted_pvp/mightring_exhaust.lua" />
    <movevent type="DeEquip" itemid="2164" slot="ring" event="function" value="onDeEquipItem"/>

mightring_exhaust.lua
Code:
local exhaust = 3 --seconds
local eStorage = 55511
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

ssa_exhaust.lua
Code:
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

Nothing happen... Any idea?
 
For those who want to change their own movemment.cpp the changes from @danielsalim1 are:

change l609
Code:
return moveEvent->fireEquip(player, item, slot, isCheck);

to l609
Code:
return moveEvent->fireEquip(player, item, slot, isCheck, true);


change l617
Code:
return moveEvent->fireEquip(player, item, slot, isRemoval);

to l617
Code:
return moveEvent->fireEquip(player, item, slot, isRemoval, false);

change l1227
Code:
bool MoveEvent::fireEquip(Player* player, Item* item, slots_t slot, bool boolean)

to l1227
Code:
bool MoveEvent::fireEquip(Player* player, Item* item, slots_t slot, bool boolean, bool equip)

change l1230
Code:
return executeEquip(player, item, slot, boolean);

to l1230
Code:
return executeEquip(player, item, slot, boolean, equip);


change l1235
Code:
    bool MoveEvent::executeEquip(Player* player, Item* item, slots_t slot, bool boolean)

to l1235
Code:
bool MoveEvent::executeEquip(Player* player, Item* item, slots_t slot, bool boolean, bool equip)
 
Back
Top