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

Lua TFS 1.2 Hide items atributes

danylook2

Member
Joined
Dec 17, 2011
Messages
63
Reaction score
5
Location
United Kingdom, Birmingham
Hi everyone how to hide items level and attributes like this
Lua:
ring (protection physical +20%, energy +20%, earth +20%, fire +20%, ice +20%, holy +20%, death +20%)
please help
 
There is no function to hide the attributes, in fact nobody would want to do that, Oops, you yes :D
If you only want to hide the description of a single item, you can do a little trick in the Player:onLook event but if you want to do this with many items, you probably need a system for your comfort, so I wait for your answer to help you
 
Thanks for answer you mean its not possible to hide this description like this you have 20 % ice and yes i am interesting its better then nothing
Post automatically merged:

Please help mate
 
Last edited:
Even tho Sarah Wesker is absolutely right about that hiding description thing, I think I know what you're trying to achieve.
If you're using a downgraded distribution where resistances to some elements don't exist, some items might be left with those unwanted "leftovers".

So for example if you want to get rid of earth resistance from silver amulet:
1.jpg

You should go to ots/items/items.xml and look for its itemId:
XML:
<item id="2170" article="a" name="silver amulet">
    <attribute key="weight" value="500" />
    <attribute key="slotType" value="necklace" />
    <attribute key="charges" value="200" />
    <attribute key="showcharges" value="1" />
    <attribute key="absorbPercentEarth" value="10" />
    <attribute key="showattributes" value="1" />
</item>

You can just delete line:
XML:
<attribute key="absorbPercentEarth" value="10" />

and you are ready to go:
2.jpg


Just be aware that this doesn't hide attributes. It gets rid of them!
I also want to point out that in this case poison resistance should be placed instead of earth resistance and it might need an additional effort to make it work properly. Of course if it is what you're looking for.
 
Yes its one point i all ready did i remove all that useless but on the other hand i try achieve to hide compliantly attributes like it was on old distribution if you know what i mean so i try compile all this if anybody know what i mean thanks for all replays i hope someone have solution for my problem
 
Like in old school distribution there was mystic turban for example that give you more magic but it was not show in items when you look in it in game client achieve anyway i try describe this right if i could so this is hard i think
 
In this case you can go to ots/movements/movements.xml
and add some custom on equip item script. Just search otland for "OnEquip" examples.

XML:
<movevent event="Equip" itemid="2663" slot="head" script="yourCustomOnEquipItem.lua" />
<movevent event="DeEquip" itemid="2663" slot="head" script="yourCustomOnDeEquipItem.lua" />
 
Last edited:
Yes i looked and i cant find functions maybe anyone can show where i need to look to solve this

Oh boy. Here we go again...
Otland is full of examples of this function. I don't know why it was that difficult. Searching for "onEquip" phrase gives many results.

Nevermind. I'm quite busy (read lazy), but I'll give you a fast and crude example. Just don't treat it as ultimate solution. Probably there are tons of better solutions for your mystic turban thingie.


open your ots/movements/movements.xml and add:
XML:
<movevent event="Equip" itemid="2663" slot="head" function="onEquipItem" script="customMysticTurban.lua" />
<movevent event="DeEquip" itemid="2663" slot="head" function="onDeEquipItem" script="customMysticTurban.lua" />

then go to your ots/movements/scripts folder and create file: customMysticTurban.lua
then open this file and copy paste this:

Lua:
--------------------------------------------------------------------------------------
eventCheckHead = {}
--------------------------------------------------------------------------------------
function table.removeKey(table, key)
    local element = table[key]
    table[key] = nil
    return element
end
--------------------------------------------------------------------------------------
local magicBuff = Condition(CONDITION_ATTRIBUTES)
magicBuff:setParameter(CONDITION_PARAM_TICKS, 15 * 1000)
magicBuff:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 4)
magicBuff:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
--------------------------------------------------------------------------------------
local function checkHead(creatureUid)
    local cid = Creature(creatureUid)
    local player = cid:getPlayer()
    if getPlayerSlotItem(cid, CONST_SLOT_HEAD).itemid == 2663 then
        player:addCondition(magicBuff)
        if (eventCheckHead[creatureUid]~=nil) then stopEvent(eventCheckHead[creatureUid]) end
        eventCheckHead[creatureUid] = addEvent(checkHead, 10*1000, creatureUid)
    else
        table.removeKey(eventCheckHead, creatureUid)
    end
end
--------------------------------------------------------------------------------------
function onEquip(cid, item, slot)
    checkHead(cid.uid)
    return true
end
--------------------------------------------------------------------------------------
function onDeEquip(cid, item, slot)
    local player = cid:getPlayer()
    if player:getCondition(CONDITION_ATTRIBUTES) then
        player:removeCondition(CONDITION_ATTRIBUTES)
    end
    if (eventCheckHead~=nil) then stopEvent(eventCheckHead) end
    Game.sendAnimatedText("Next time I will do my homework on my own.", getCreaturePosition(cid), TEXTCOLOR_LIGHTBLUE)
    table.removeKey(eventCheckHead, cid.uid)
    return true
end
--------------------------------------------------------------------------------------

Now launch your ots and put mystic turban on. Then take it off. Here you are. Fast and crude onEquip example.
 
Last edited:
Instead of removing all attributes you can simply change
Lua:
<attribute key="showattributes" value="1" />
to
Lua:
<attribute key="showattributes" value="0" />

U sure this works for all items? I made a test to check if it hides magic level buff:
XML:
<item id="2323" article="a" name="custom item hat of the mad">
    <attribute key="description" value="OTLAND TEST: You have a vague feeling that it looks somewhat silly." />
    <attribute key="weight" value="700" />
    <attribute key="armor" value="3" />
    <attribute key="magiclevelpoints" value="1" />
    <attribute key="slotType" value="head" />
    <attribute key="absorbPercentEnergy" value="10" />
    <attribute key="showattributes" value="0" />
</item>

And I got this result:

1.jpg


Edit: You know what? It doesn't matter. Why on earth anyone would like to hide magic level buff. It's just a whim, and it's not worth wasting our time.
 
Last edited:
Yesss right this is not working correctly it dose not hide all attributes but i understood its work on some attributes i looking for better solution i check this one all ready and that's why i should tell you in first place that i did this and its not working as supposed Axelot mention that maybe its PlayerOnLook Function or something else i don't know yet but we are close i think
 
Axelot mention that maybe its PlayerOnLook Function
Not me. It was an idea of Sarah Wesker.
And you either use custom player: onLook function to hide magiclevelpoints given by xml or use custom onEquip function with example given above or similar. I think there is no other way to get, what you're looking for.
 
Yes it's my mistake and this function don't work properly
Lua:
<attribute key="showattributes" value="1" />
second i don't know how to use this function that's why i was waiting for little example or help with that think
this code is not a function and its not written in lua
This is an attribute of item written in xml file. It must be placed between <item> and </item> tags.
If you search for "strange talisman" in items.xml you will find an example.
If you're looking for ready example of lua function i already did customMysticTurban.lua for you. Look above and try it.
 
Last edited:
U sure this works for all items? I made a test to check if it hides magic level buff:
XML:
<item id="2323" article="a" name="custom item hat of the mad">
    <attribute key="description" value="OTLAND TEST: You have a vague feeling that it looks somewhat silly." />
    <attribute key="weight" value="700" />
    <attribute key="armor" value="3" />
    <attribute key="magiclevelpoints" value="1" />
    <attribute key="slotType" value="head" />
    <attribute key="absorbPercentEnergy" value="10" />
    <attribute key="showattributes" value="0" />
</item>

And I got this result:

View attachment 57880


Edit: You know what? It doesn't matter. Why on earth anyone would like to hide magic level buff. It's just a whim, and it's not worth wasting our time.
The reason it doesn't work is because the item has Armor.

item.cpp
C++:
} else if (it.armor != 0 || (item && item->getArmor() != 0) || it.showAttributes) {
 
The reason it doesn't work is because the item has Armor.
I didn't dig to cpp file because I still don't think that hiding item attributes from players is something that should be desirable. I just used this example as an argument to show that you can't (easily) hide any argument from any item. However thanks for making it clear.
 
Back
Top