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

(Actions) Item's upgrading by jewels ver. 3 [FOR TFS 0.3.6]

try.
Switch must be north of item, like picture.
Added magic effect to show proper square, for testing. Can be removed. (line 49)
as per original script, 1 small ruby required.
add actionid to switch, same as below.
itemid 1945.
XML:
<action actionid="45001" event="script" value="switch_upgrade_item.lua"/>
Lua:
local conf = {}
conf["level"] = {
-- [item_level] = {successParcent=PARCENT FOR UPGRADING SUCCESS, downrageLevel = IF UPGRADING FAIL - ITEM WAS DECRASED TO LEVEL HERE}
   [1] = {successParcent = 85, downrageLevel = 0},
   [2] = {successParcent = 80, downrageLevel = 1},
   [3] = {successParcent = 75, downrageLevel = 2},
   [4] = {successParcent = 70, downrageLevel = 3},
   [5] = {successParcent = 65, downrageLevel = 4},
   [6] = {successParcent = 60, downrageLevel = 5},
   [7] = {successParcent = 55, downrageLevel = 0},
   [8] = {successParcent = 50, downrageLevel = 0},
   [9] = {successParcent = 45, downrageLevel = 0}
}
conf["upgrade"] = { -- how many parcent attributes are rised?
   attack = 5, -- attack %
   extraAttack = 10, -- extra Attack %
   defense = 5, -- defence %
   extraDefense = 10, -- extra defence %
   armor = 5, -- armor %
   hitChance = 5, -- hit chance %
}
-- // do not touch // --
-- Upgrading system v.3.1 by Azi [Ersiu] --
local upgrading = {
   upValue = function (value, level, parcent)
       if(not(value>0))then return 0 end
       for i=1,level do
           value = math.ceil(((value/100)*parcent)+value)+1
       end
       return (value > 0) and value or 0
   end,
 
   getLevel = function (item)
       local name = string.explode(getItemName(item), '+')
       return (#name == 1) and 0 or math.abs(name[2])
   end,
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
   if item.itemid == 1946 then
       doPlayerSendTextMessage(cid, 22, "Switch reset.")
       doTransformItem(item.uid, 1945)
       return true
   end
   if getPlayerItemCount(cid, 2147) < 1 then
       doPlayerSendTextMessage(cid, 19, "Sorry, 1 small ruby required to be carried by player for upgrade.")
       return true
   end
   local thing = getThingFromPos({x = toPosition.x, y = toPosition.y + 1, z = toPosition.z})
   doSendMagicEffect({x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}, CONST_ME_TUTORIALSQUARE)
   local getItem = getItemInfo(thing.itemid)
   if((getItem.weaponType > 0 or getItem.armor > 0) and not isItemStackable(thing.itemid))then
       local level = upgrading.getLevel(thing.uid)
       if(level < #conf["level"])then
           local nLevel = (conf["level"][(level+1)].successParcent >= math.random(1,100)) and (level+1) or conf["level"][level].downrageLevel
           if(nLevel > level)then
               doSendMagicEffect({x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}, 30)
               doPlayerSendTextMessage(cid, 22, "Congratz! Upgraded was successful, your item has become stronger!")
           else
               doSendMagicEffect({x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}, 2)
               doPlayerSendTextMessage(cid, 22, "Argh! Upgrading fail... you item lost some of strong!")
           end
           doItemSetAttribute(thing.uid, "name", getItem.name..((nLevel>0) and "+"..nLevel or ""))
           doItemSetAttribute(thing.uid, "attack",  upgrading.upValue(getItem.attack, nLevel, conf["upgrade"].attack))
           doItemSetAttribute(thing.uid, "extraattack", upgrading.upValue(getItem.extraAttack, nLevel, conf["upgrade"].extraAttack))
           doItemSetAttribute(thing.uid, "defense", upgrading.upValue(getItem.defense,nLevel, conf["upgrade"].defense))
           doItemSetAttribute(thing.uid, "extradefense", upgrading.upValue(getItem.extraDefense, nLevel, conf["upgrade"].extraDefense))
           doItemSetAttribute(thing.uid, "armor", upgrading.upValue(getItem.armor, nLevel, conf["upgrade"].armor))
           doItemSetAttribute(thing.uid, "hitChance", upgrading.upValue(getItem.hitChance,nLevel, conf["upgrade"].hitChance))
           doPlayerRemoveItem(cid, 2147, 1)
           doTransformItem(item.uid, 1946)
       else
           doPlayerSendTextMessage(cid, 19, "Sorry this item is on max level.")
       end
   else
       doPlayerSendTextMessage(cid, 19, "You cannot upgrade this item.")
   end
end
 
The script working but i testet on many items but its says "You cannot upgrade this item."
I didn't change how the script functions. I only made it usable by the lever, as requested.
I suggest posting a new thread in support, to aide you in fixing any issues with the script itself.
 
Back
Top