Bump. TFS 1.2/1.3Sorry to revive an old thread, but is there any way to add +ml to this system? phys resistance, etc?
In 1.0 the arguments for almost all the interface's are different.tfs 1.2 error
![]()
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()
tfs 1.2 error
![]()
Read the whole thing.This script requires these functions to work: [TFS 1.1] attributes functions from 0.3.7
you are the best troll, on this forum i ever seeRead the whole thing.
i change cid to player on action/upgrading.luaIn 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.
Always resolve 1 problem at a time, if you have any further issues/errors just post them here.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()
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
I'll re-write the whole thing for you later when i get home for work and make it compatible with all of 1.xi change cid to player on action/upgrading.lua
but still the same error
or i do someting wrong?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
error:
![]()
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.
add in first lineYo 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?
local blocked_id = {ItemID}
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
have only one fileThanks, but still crashes.
Just to be clear, in what file did u mean?![]()
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