• 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

Its fully working on TFS 1.2. I added the functions at the end of global.lua and added the script to actions and its working perfect!
Thanks!
 
Works perfect on OTX3 (based on tfs 1.3)

Sorry to revive an old thread, but is there any way to add +ml to this system? phys resistance, etc?

Thank you so much for rewriting this.
 
Last edited:
tfs 1.2 error
Screen_Shot_11-03-17_at_10.21_AM.png
 
tfs 1.2 error
Screen_Shot_11-03-17_at_10.21_AM.png
In 1.0 the arguments for almost all the interface's are different.
1.0 -
onUse(cid, item, fromPosition, itemEx, toPosition)
1.2/1.3
onUse(player, item, fromPosition, target, toPosition, isHotkey)

The the most important argument we are interested in here when converting scripts from 1.0 to 1.2 and above is cid and player, cid holds a numerical value where as player holds userdata.

Now it the name doesn't really matter what the arguments name is, its the value & the position of where it sits that we are interested in.
So to alleviate this we simply can write underneath onUse.
Lua:
onUse(cid, item, fromPosition, itemEx, toPosition)
    -- now in 1.2 and above cid contains the id of its userdata argument (if any)
    -- what we are doing here is writing over cid's original value
    cid = cid:getId()
Always resolve 1 problem at a time, if you have any further issues/errors just post them here.
 
In 1.0 the arguments for almost all the interface's are different.
1.0 -
onUse(cid, item, fromPosition, itemEx, toPosition)
1.2/1.3
onUse(player, item, fromPosition, target, toPosition, isHotkey)

The the most important argument we are interested in here when converting scripts from 1.0 to 1.2 and above is cid and player, cid holds a numerical value where as player holds userdata.

Now it the name doesn't really matter what the arguments name is, its the value & the position of where it sits that we are interested in.
So to alleviate this we simply can write underneath onUse.
Lua:
onUse(cid, item, fromPosition, itemEx, toPosition)
    -- now in 1.2 and above cid contains the id of its userdata argument (if any)
    -- what we are doing here is writing over cid's original value
    cid = cid:getId()
Always resolve 1 problem at a time, if you have any further issues/errors just post them here.
i change cid to player on action/upgrading.lua
but still the same error

Lua:
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)
cid = cid:getId()
   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
or i do someting wrong?

error:
Screen_Shot_11-03-17_at_10.21_AM.png
 
i change cid to player on action/upgrading.lua
but still the same error

Lua:
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)
cid = cid:getId()
   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
or i do someting wrong?

error:
Screen_Shot_11-03-17_at_10.21_AM.png
I'll re-write the whole thing for you later when i get home for work and make it compatible with all of 1.x :)
 
Works perfect on OTX3 (based on tfs 1.3)

Sorry to revive an old thread, but is there any way to add +ml to this system? phys resistance, etc?

Thank you so much for rewriting this.


Yo man, using OTX here too & it just keeps crashing when used on aol/ssa/might rings etc. Even tho i put it to ignore those items.
Same issue?
 
Any possibility to make it work on wand/rods and stackable items ?
 
Yo man, using OTX here too & it just keeps crashing when used on aol/ssa/might rings etc. Even tho i put it to ignore those items.
Same issue?
add in first line
Lua:
local blocked_id = {ItemID}

and after onUse function
Lua:
if isInArray(blocked_id, itemEx.itemid) then
        return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This item can not be refined.")
    end
 
add in first line
Lua:
local blocked_id = {ItemID}

and after onUse function
Lua:
if isInArray(blocked_id, itemEx.itemid) then
        return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This item can not be refined.")
    end


Thanks, but still crashes.
Just to be clear, in what file did u mean? :rolleyes:
 
Thanks, but still crashes.
Just to be clear, in what file did u mean? :rolleyes:
have only one file
Lua:
local blocked_id = {1212, 1111}
local conf = {
   ["level"] = {
   -- [item_level] = {successPercent= CHANCE TO UPGRADE ITEM, downgradeLevel = ITEM GETS THIS LEVEL IF UPGRADE FAILS}
......
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
          if isInArray(blocked_id, itemEx.itemid) then return                         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This item can not be refined."
 end
 
have only one file
Lua:
local blocked_id = {1212, 1111}
local conf = {
   ["level"] = {
   -- [item_level] = {successPercent= CHANCE TO UPGRADE ITEM, downgradeLevel = ITEM GETS THIS LEVEL IF UPGRADE FAILS}
......
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
          if isInArray(blocked_id, itemEx.itemid) then return                         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This item can not be refined."
 end


Thanks, but solved it by editing alot of items to not use charges etc & just modified the attributes/resistances given by the item.

Cheers
 
If it works on 1.1 works on 1.2 and 1.3 im 99% sure it will work without any change, if there's any change will be super dumb.
 
Back
Top