• 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+ Hard one

Ascuas Funkeln

Rakkedo Game
Joined
Apr 14, 2013
Messages
549
Solutions
32
Reaction score
304
Location
Poland
GitHub
AscuasFunkeln
Hello, i need thids
And this
Lua:
function Player.getTotalArmor(self)
    local total = 0
    local slots = { CONST_SLOT_HEAD, CONST_SLOT_NECKLACE, CONST_SLOT_ARMOR, CONST_SLOT_LEGS, CONST_SLOT_FEET, CONST_SLOT_RING }
    local item
    for i = 1, #slots do
        item = self:getSlotItem(slots[i])
        if item then
            total = total + item:getType():getArmor()
        end
    end
    return total
end
Put in one thing... ??
What i mean?
Upgrade work perfect and getTotalArmor work only in "basic".
For example, if Helmet have Armor: 10, then function getTotalArmor return 10, but if we upgrade item and Helmet get now Armor: 11, function getTotalArmor return basic 10 value.
Extra armor from upgrade ofcourse work, but i have no idea where its stored and how to get it and put into getTotalArmor function.
Im not wait for "do it for me", i just need any suggestions, idea, help with solving this.
 
To change value of any items you are using doItemSetAttribute function. So, If you want check new value, just use getItemAttribute function.
Something like this:
Lua:
getItemAttribute(itemEx.uid, ITEM_ATTRIBUTE_ARMOR)
 
To change value of any items you are using doItemSetAttribute function. So, If you want check new value, just use getItemAttribute function.
Something like this:
Lua:
getItemAttribute(itemEx.uid, ITEM_ATTRIBUTE_ARMOR)
Not work, in two ways, one cause errors with "ItemEx", second show again just basic armor.

Its looks like this function dont work properly.
It work in upgrade!, but if i do something like that
Code:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    local armor = getItemAttribute(uid,'armor')
  doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, armor)
    return true
end
Even like
Code:
getItemAttribute(itemEx.uid, ITEM_ATTRIBUTE_ARMOR)
getItemAttribute(itemEx.uid, armor)
getItemAttribute(uid, 'armor')
getItemAttribute(uid, "armor")
Just nothing work
And make error in this line at global.lua
Code:
function getItemAttribute(uid, key)
   local i = ItemType(Item(uid):getId()) -- THERE ARE ERROR
   local string_attributes = {
     [ITEM_ATTRIBUTE_NAME] = i:getName(),
     [ITEM_ATTRIBUTE_ARTICLE] = i:getArticle(),
     [ITEM_ATTRIBUTE_PLURALNAME] = i:getPluralName(),
     ["name"] = i:getName(),
     ["article"] = i:getArticle(),
     ["pluralname"] = i:getPluralName()
   }
   local numeric_attributes = {
     [ITEM_ATTRIBUTE_WEIGHT] = i:getWeight(),
     [ITEM_ATTRIBUTE_ATTACK] = i:getAttack(),
     [ITEM_ATTRIBUTE_DEFENSE] = i:getDefense(),
     [ITEM_ATTRIBUTE_EXTRADEFENSE] = i:getExtraDefense(),
     [ITEM_ATTRIBUTE_ARMOR] = i:getArmor(),
     [ITEM_ATTRIBUTE_HITCHANCE] = i:getHitChance(),
     [ITEM_ATTRIBUTE_SHOOTRANGE] = i:getShootRange(),
     ["weight"] = i:getWeight(),
     ["attack"] = i:getAttack(),
     ["defense"] = i:getDefense(),
     ["extradefense"] = i:getExtraDefense(),
     ["armor"] = i:getArmor(),
     ["hitchance"] = i:getHitChance(),
     ["shootrange"] = i:getShootRange()
   }
  
   local attr = Item(uid):getAttribute(key)
   if tonumber(attr) then
     if numeric_attributes[key] then
       return attr ~= 0 and attr or numeric_attributes[key]
     end
   else
     if string_attributes[key] then
       if attr == "" then
         return string_attributes[key]
       end
     end
   end
return attr
end
 
Last edited:
Back
Top