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

Action [TFS 1.1] Item's upgrading by jewels

i liked this script a lot !! but i'm having this errors on testing, using TFS 1.3, someone can help me fix this? sorry if iv'e missed something, or if i didnt notice a reply that solve this

upgradeerror.png

thanks in advance!! regards

edit: ok it seems ive solved getItemAttribute by adding item_attribute.lua on lib folder, but now im having this error when using a upgrading crystal on a devil helmet

upgrade_error2.png

i suppose that the reason of this error is that the first upgrade (level 1) need to be 100% chance, if it fails, the error is shown in the console :S
 
Last edited:
I`m trying to add this script to my TFS 1.3, but it doesn't work.
If i only use the jewel(talon in my case) it gives me an error.

I get this in the console:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/upgrading.lua:onUse
data/lib/Misc/item_attributes.lua:2: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data/lib/Misc/item_attributes.lua:2: in function 'getItemAttribute'
        data/actions/scripts/other/upgrading.lua:57: in function <data/actions/scripts/other/upgrading.lua:51>

The code where it goes wrong looks like this:

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    cid = player:getId()
    itemEx = target

    local it = ItemType(itemEx.itemid)

if((it:getWeaponType() > 0 or getItemAttribute(itemEx.uid, ITEM_ATTRIBUTE_ARMOR) > 0) and not isItemStackable(itemEx.itemid))then
    local level = upgrading.getLevel(itemEx.uid)
    if(level < #conf["level"])then
      local nLevel = (conf["level"][(level+1)].successPercent >= math.random(1,100)) and (level+1) or conf["level"][level].downgradeLevel
      if(nLevel > level)then
        doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Upgrade to level " .. nLevel .. " successful!")
      else
        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Upgrade failed. Your " .. it:getName() .. " is now on level " .. nLevel .. "")
      end
      doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_NAME, it:getName()..((nLevel>0) and "+"..nLevel or ""))
      doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_ATTACK,  upgrading.upValue(it:getAttack(), nLevel, conf["upgrade"].attack))
      doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_DEFENSE, upgrading.upValue(it:getDefense(), nLevel, conf["upgrade"].defense))
      doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_EXTRADEFENSE, upgrading.upValue(it:getExtraDefense(), nLevel, conf["upgrade"].extraDefense))
      doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_ARMOR, upgrading.upValue(it:getArmor(), nLevel, conf["upgrade"].armor))
      doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_HITCHANCE, upgrading.upValue(it:getHitChance(), nLevel, conf["upgrade"].hitChance))
      doRemoveItem(item.uid, 1)
    else
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your " .. it:getName() .. " is on max level alredy.")
    end
  else
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot upgrade this item.")
  end
end

And the code at item_attributes:
Lua:
function getItemAttribute(uid, key)
   local i = ItemType(Item(uid):getId())
   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
 
Bump, anyone? it must be something obvious I guess?
 
I`m trying to add this script to my TFS 1.3, but it doesn't work.
If i only use the jewel(talon in my case) it gives me an error.

I get this in the console:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/upgrading.lua:onUse
data/lib/Misc/item_attributes.lua:2: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data/lib/Misc/item_attributes.lua:2: in function 'getItemAttribute'
        data/actions/scripts/other/upgrading.lua:57: in function <data/actions/scripts/other/upgrading.lua:51>

The code where it goes wrong looks like this:

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    cid = player:getId()
    itemEx = target

    local it = ItemType(itemEx.itemid)

if((it:getWeaponType() > 0 or getItemAttribute(itemEx.uid, ITEM_ATTRIBUTE_ARMOR) > 0) and not isItemStackable(itemEx.itemid))then
    local level = upgrading.getLevel(itemEx.uid)
    if(level < #conf["level"])then
      local nLevel = (conf["level"][(level+1)].successPercent >= math.random(1,100)) and (level+1) or conf["level"][level].downgradeLevel
      if(nLevel > level)then
        doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Upgrade to level " .. nLevel .. " successful!")
      else
        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Upgrade failed. Your " .. it:getName() .. " is now on level " .. nLevel .. "")
      end
      doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_NAME, it:getName()..((nLevel>0) and "+"..nLevel or ""))
      doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_ATTACK,  upgrading.upValue(it:getAttack(), nLevel, conf["upgrade"].attack))
      doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_DEFENSE, upgrading.upValue(it:getDefense(), nLevel, conf["upgrade"].defense))
      doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_EXTRADEFENSE, upgrading.upValue(it:getExtraDefense(), nLevel, conf["upgrade"].extraDefense))
      doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_ARMOR, upgrading.upValue(it:getArmor(), nLevel, conf["upgrade"].armor))
      doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_HITCHANCE, upgrading.upValue(it:getHitChance(), nLevel, conf["upgrade"].hitChance))
      doRemoveItem(item.uid, 1)
    else
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your " .. it:getName() .. " is on max level alredy.")
    end
  else
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot upgrade this item.")
  end
end

And the code at item_attributes:
Lua:
function getItemAttribute(uid, key)
   local i = ItemType(Item(uid):getId())
   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
cid = player:getId()
itemEx = target
Wtf was that? Delete this 2 lines what does do anything, and post error without that, if it appear...
 
cid = player:getId()
itemEx = target
Wtf was that? Delete this 2 lines what does do anything, and post error without that, if it appear...

I removed that and changed cid in code to player:getId()

I still get the same error, which feels weird cause i only use the jewel. I`m not even using the the jewel on an item yet.

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/upgrading.lua:onUse
data/lib/Misc/item_attributes.lua:2: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data/lib/Misc/item_attributes.lua:2: in function 'getItemAttribute'
        data/actions/scripts/other/upgrading.lua:57: in function <data/actions/scripts/other/upgrading.lua:51>
 
Last edited:
I removed that and changed cid in code to player:getId()

I still get the same error, which feels weird cause i only use the jewel. I`m not even using the the jewel on an item yet.

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/upgrading.lua:onUse
data/lib/Misc/item_attributes.lua:2: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data/lib/Misc/item_attributes.lua:2: in function 'getItemAttribute'
        data/actions/scripts/other/upgrading.lua:57: in function <data/actions/scripts/other/upgrading.lua:51>
Talon right? U setup in dat(objecxtbuilder+items.otmb) multiusing for it? Cuz now server trigger using this talon just like that, not on the target item...
 
I gathered some more information using print:
print(it) userdata: 0x287ac3d0
print(target.uid) 0
print(ITEM_ATTRIBUTE_ARMOR) 8192


So as expected the target.uid = 0 which is true since i only started the use and not on something yet.

@Ascuas Funkeln
Ohh i have to change it over there as well? I did not know that, it doesn't state so in the starting post.
Then I have to put this on hold, since I have no idea how that works.
And as far as I do know objecxtbuilder isn' t supported for 10.98
Post automatically merged:

Okay, i got it working the objectbuilder and item editor were not that difficult to understand.
Also the 10.98 client apparently uses the same otb as 10.97.

got it working thanks for the help @Ascuas Funkeln
 
Last edited:
working perfectly on tfs 1.3 revscript sys ^^ after using this at the bottom of global.lua
Lua:
function getItemAttribute(uid, key)
   local i = ItemType(Item(uid):getId())
   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(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

function doItemSetAttribute(uid, key, value)
   return Item(uid):setAttribute(key, value)
end

function doItemEraseAttribute(uid, key)
   return Item(uid):removeAttribute(key)
end[/lua]
 
working perfectly on tfs 1.3 revscript sys ^^ after using this at the bottom of global.lua
Lua:
function getItemAttribute(uid, key)
   local i = ItemType(Item(uid):getId())
   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(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

function doItemSetAttribute(uid, key, value)
   return Item(uid):setAttribute(key, value)
end

function doItemEraseAttribute(uid, key)
   return Item(uid):removeAttribute(key)
end[/lua]

why can i use it just on shields and weapons?

upgrade.png
 
why can i use it just on shields and weapons?

View attachment 43908

Hi, to fix visit this thread
If you want the shortcut... Well, you can go to your global.lua and search for
Lua:
local attr = Item(item.uid):getAttribute(key)

then change it to
Lua:
local attr = Item(uid):getAttribute(key)

also add this to the beggining of the table on upgrading.lua
Lua:
[0] = {downgradeLevel = 0},

the system is really amazing, but, it feels unbalanced since you can't add magic level to spellbooks :rolleyes:
 
Hi, to fix visit this thread
If you want the shortcut... Well, you can go to your global.lua and search for
Lua:
local attr = Item(item.uid):getAttribute(key)

then change it to
Lua:
local attr = Item(uid):getAttribute(key)

also add this to the beggining of the table on upgrading.lua
Lua:
[0] = {downgradeLevel = 0},

the system is really amazing, but, it feels unbalanced since you can't add magic level to spellbooks :rolleyes:

thank you mate but i don't have nothing like that in global.lua :p
 
thank you mate but i don't have nothing like that in global.lua :p

add this to the bottom of your global.lua
Lua:
function getItemAttribute(uid, key)
   local i = ItemType(Item(uid):getId())
   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

function doItemSetAttribute(uid, key, value)
   return Item(uid):setAttribute(key, value)
end

function doItemEraseAttribute(uid, key)
   return Item(uid):removeAttribute(key)
end
 
hello guys I have a problem.
I use this script on my server and it just make my weapon for example +5 but atk is still the same :( you know maybe what is wrong?

Lua Script Error: [Action Interface]
data/actions/scripts/misc/upgrade.lua:eek:nUse
data/actions/scripts/misc/upgrade.lua:61: attempt to call method 'getExtraDefense' (a nil value)
stack traceback:
[C]: in function 'getExtraDefense'
data/actions/scripts/misc/upgrade.lua:61: in function <data/actions/scripts/misc/upgrade.lua:45>
 
Last edited:
Hello, script is working but when i use item to upgrade on myself i get this error. Im using tfs 1.2. Help me

Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/other/cup.lua:onUse
data/upgrade.lua:2: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data/upgrade.lua:2: in function 'getItemAttribute'
        data/actions/scripts/other/cup.lua:53: in function <data/actions/scripts/other/cup.lua:50>
 
This is a very very old upgrade system(April 22 2010). It was so good that it deserved to be rewritten.

Credits: @Azi
original thread(0.3.6): Action - Item's upgrading by jewels ver. 3 [FOR TFS 0.3.6] (http://otland.net/threads/items-upgrading-by-jewels-ver-3-for-tfs-0-3-6.79098/)







This script requires these functions to work: [TFS 1.1] attributes functions from 0.3.7

Code:
<action itemid="xxxx" script="upgrading.lua"/>

upgrading.lua:
Code:
local conf = {
   ["level"] = {
   -- [item_level] = {successPercent= CHANCE TO UPGRADE ITEM, downgradeLevel = ITEM GETS THIS LEVEL IF UPGRADE FAILS}
     [1] = {successPercent = 85, downgradeLevel = 0},
     [2] = {successPercent = 80, downgradeLevel = 1},
     [3] = {successPercent = 75, downgradeLevel = 2},
     [4] = {successPercent = 70, downgradeLevel = 3},
     [5] = {successPercent = 65, downgradeLevel = 4},
     [6] = {successPercent = 60, downgradeLevel = 5},
     [7] = {successPercent = 55, downgradeLevel = 0},
     [8] = {successPercent = 50, downgradeLevel = 0},
     [9] = {successPercent = 45, downgradeLevel = 0}
   },

   ["upgrade"] = { -- how many percent attributes are rised?
     attack = 5, -- attack %
     defense = 5, -- defense %
     extraDefense = 10, -- extra defense %
     armor = 5, -- armor %
     hitChance = 5, -- hit chance %
   }
}



-- // do not touch // --
-- Upgrading system by Azi [Ersiu] --
-- Edited for TFS 1.1 by Zbizu --

local upgrading = {
  upValue = function (value, level, percent)
  if value < 0 then return 0 end
     if level == 0 then return value end
     local nVal = value
     for i = 1, level do
       nVal = nVal + (math.ceil((nVal/100*percent)))
     end
  return nVal > 0 and nVal or value
  end,

  getLevel = function (item)
  local name = Item(item):getName():split('+')
     if (#name == 1) then
       return 0
     end
 
     return math.abs(name[2])
  end,
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local it = ItemType(itemEx.itemid)
  if((it:getWeaponType() > 0 or getItemAttribute(itemEx.uid, ITEM_ATTRIBUTE_ARMOR) > 0) and not isItemStackable(itemEx.itemid))then
  local level = upgrading.getLevel(itemEx.uid)
  if(level < #conf["level"])then
  local nLevel = (conf["level"][(level+1)].successPercent >= math.random(1,100)) and (level+1) or conf["level"][level].downgradeLevel
  if(nLevel > level)then
  doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Upgrade to level " .. nLevel .. " successful!")
  else
  doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Upgrade failed. Your " .. it:getName() .. " is now on level " .. nLevel .. "")
  end
  doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_NAME, it:getName()..((nLevel>0) and "+"..nLevel or ""))
  doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_ATTACK,  upgrading.upValue(it:getAttack(), nLevel, conf["upgrade"].attack))
  doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_DEFENSE, upgrading.upValue(it:getDefense(), nLevel, conf["upgrade"].defense))
  doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_EXTRADEFENSE, upgrading.upValue(it:getExtraDefense(), nLevel, conf["upgrade"].extraDefense))
  doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_ARMOR, upgrading.upValue(it:getArmor(), nLevel, conf["upgrade"].armor))
  doItemSetAttribute(itemEx.uid, ITEM_ATTRIBUTE_HITCHANCE, upgrading.upValue(it:getHitChance(), nLevel, conf["upgrade"].hitChance))
  doRemoveItem(item.uid, 1)
  else
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your " .. it:getName() .. " is on max level alredy.")
  end
  else
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot upgrade this item.")
  end
end
Very nice system.
Im trying to understand here:
Lua:
local nLevel = (conf["level"][(level+1)].successPercent >= math.random(1,100)) and (level+1) or conf["level"][level].downgradeLevel
In order to "prevent a downgradeLevel" getting for example a potion in backpack, it will not downgrade, but if you dont have it, it will downgradeLevel.
Like a "prevent break or prevent downgrade"
How we can write this ? I tried with if cid:doRemoveItem(xxx,1) then, action, else ... Upgrade Failed and downgrade.
 
Back
Top