• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Mana max itens

natanal99

New Member
Joined
May 31, 2011
Messages
67
Reaction score
3
So, i got this item that when used add 1 mana max to player who did it.
Then i added equips that grants manaMax to player and the item do not works how it should if the player is equipping some of this equips, cuz getCreatureMaxMana return the player max mana counting the equips but setCreatureMaxMana sets it without counting the equips.

Exemple:
player have 100MP
player have equip that grats +30MP
player uses item that grats +1MP but instead gains +31MP

Someone know a way i can get the player mana ignoring the equips? it could be source, no problem.
ps: tfs 0.3.6
 
To answer your question, use subId and apply it as a condition, you can check the equipment per slot using getPlayerSlotItem or getSlotItem, depending on the distro.
I was at work when I was writing this..
Some thing like this.
Code:
-- 1.1+
local condition = {}
local amount = 120 -- 20%

local items = {
    uid here, -- use the index to correspond to the slot
    uid here, -- 2
    uid here, -- 3
    uid here, -- 4
    uid here, -- 5
    uid here, -- 6
    uid here, -- 7
    uid here, -- 8
    uid here, -- 9
    uid here, -- 10
}

local p = {}

for subId, uid in pairs(items) do
    condition[uid] = Condition(CONDITION_ATTRIBUTES)
    condition[uid]:setParameter(CONDITION_PARAM_SUBID, subId)
    condition[uid]:setParameter(CONDITION_PARAM_TICKS, -1)
    condition[uid]:setParameter(CONDITION_PARAM_STAT_MAXMANAPERCENT, amount)
end

function onEquip(item, slot)
    for slot, uid in pairs(items) do
        if uid == player:getSlotItem(slot):getUniqueId() then
            player:addCondition(condition[uid])
            p[uid].subId = slot
        end
    end
    return true
end

function onDeEquip(item, slot)
    doRemoveCondition(player:getId(), CONDITION_ATTRIBUTES, p[item.uid].subId)
    return true
end
 
Last edited by a moderator:
Back
Top