• 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 1.X+ Is it possible to print [protection all] ( item attribute ) in lua?

Solution
This can serve as an example, but I have not really tried it
Lua:
local function getProtectionAll(item)
    local absorbPercents = item:getType():getAbilities()['absorbPercent']
    local count = absorbPercents[0]
    if count ~= 0 then
        for index = 1, 11 do
            if absorbPercents[index] ~= count then
                return 0
            end
        end
    end
    return count
end
local function getPlayerProtectionAll(player)
    local count = 0
    for slot = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
        local item = player:getSlotItem(slot)
        if item then
            count = count + getProtectionAll(item)
        end
    end
    return count
end
This can serve as an example, but I have not really tried it
Lua:
local function getProtectionAll(item)
    local absorbPercents = item:getType():getAbilities()['absorbPercent']
    local count = absorbPercents[0]
    if count ~= 0 then
        for index = 1, 11 do
            if absorbPercents[index] ~= count then
                return 0
            end
        end
    end
    return count
end
local function getPlayerProtectionAll(player)
    local count = 0
    for slot = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
        local item = player:getSlotItem(slot)
        if item then
            count = count + getProtectionAll(item)
        end
    end
    return count
end
 
Last edited:
Solution
Back
Top