Barbyn
Founder of Granaria 09/10
- Joined
- Jun 13, 2007
- Messages
- 167
- Reaction score
- 1
Here is a script that "works" for TFS 0.3.6 but still not :/. We could all help fix this. All it does is really to upgrade "itemname" but when you upgrade your item, you get item+1. And it doesn't add anything else nor does the item gets removed (the item you press to get the other item upgraded) the second time you try to upgrade it, it only changes your item to +1 (over and over and over again) and can't go any further. The item may break anyway. Please do try this and you'll see what I mean. It's kinda buggy but well, the error in console gives:
Server Console Error:
And now the Script:
Let's solve this now !
Server Console Error:
Lua:
[Error - Action Interface]
data/actions/scripts/upgrade.lua:onUse
Description:
data/actions/scripts/upgrade.lua:23: attempt to compare number with nil
stack traceback:
data/actions/scripts/upgrade.lua:23: in function <data/actions/scripts/u
pgrade.lua:10>
And now the Script:
Lua:
--Item Upgrading released by granaria.hopto.org for TFS 0.3.6
--Another guy made this script(TFS 0.3.5), I don't know who it was. I'll not take credit for this script whatsoever.
config = {
brokeChance = 5,
upgradePercent = 8,
maxUpgrade = 50,
notAllowed = {}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local getUpgraded = itemEx.actionid-10000
if getUpgraded < 0 then
getUpgraded = 0
end
if getUpgraded < config.maxUpgrade then
if itemEx.itemid > 100 then
if isItemMoveable(itemEx.itemid) == TRUE and isItemRune(itemEx.itemid) == FALSE and isCorpse(itemEx.uid) == FALSE and isContainer(itemEx.uid) == FALSE and isItemStackable(itemEx.itemid) == FALSE and isItemFluidContainer(itemEx.itemid) == FALSE and isInArray(config.notAllowed, itemEx.itemid) == FALSE then
if config.brokeChance <= math.random(1, 100) then
doItemSetAttribute(itemEx.uid, "name", getItemNameById(itemEx.itemid) .. "+" .. (getUpgraded+1))
doItemSetAttribute(itemEx.uid, "actionid", 10000+(getUpgraded+1))
doSendMagicEffect(toPosition, 30)
doPlayerSendTextMessage(cid, 22, "You successfuly upgraded " .. getItemNameById(itemEx.itemid) .. " to " .. (getUpgraded+1) .. " level.")
if getItemAttribute(itemEx.uid, "attack") > 0 then
doItemSetAttribute(itemEx.uid, "attack", (getItemAttribute(itemEx.uid, "attack")+((getItemAttribute(itemEx.uid, "attack")/100)*config.upgradePercent))+1)
end
if getItemAttribute(itemEx.uid, "extraattack") > 0 then
doItemSetAttribute(itemEx.uid, "extraattack", (getExtraItemAttack(itemEx.uid)+((getExtraItemAttack(itemEx.uid)/100)*config.upgradePercent))+1)
end
if getItemAttribute(itemEx.uid, "defense") > 0 then
doItemSetAttribute(itemEx.uid, "defense", (itemEx.uid), (getItemAttribute(itemEx.uid, "defense")+((getItemAttribute(itemEx.uid, "defense")/100)*config.upgradePercent))+1)
end
if getItemAttribute(itemEx.uid, "extradefense") > 0 then
doItemSetAttribute(itemEx.uid, "extradefense", (itemEx.uid), (getItemAttribute(itemEx.uid, "extradefense")+((getItemAttribute(itemEx.uid, "extradefense")/100)*config.upgradePercent))+1)
end
if getItemAttribute(itemEx.uid, "armor") > 0 then
doItemSetAttribute(itemEx.uid, "armor", (itemEx.uid), (getItemAttribute(itemEx.uid, "armor")+((getItemAttribute(itemEx.uid, "armor")/100)*config.upgradePercent))+1)
end
if getItemAttribute(itemEx.uid, "attackspeed") > 0 then
doItemSetAttribute(itemEx.uid, "attackspeed", (itemEx.uid), (getItemAttribute(itemEx.uid, "attackspeed")+((getItemAttribute(itemEx.uid, "attackspeed")/100)*config.upgradePercent))+1)
end
if getItemAttribute(itemEx.uid, "hitchance") > 0 then
doItemSetAttribute(itemEx.uid, "hitchance", (itemEx.uid), (getItemAttribute(itemEx.uid, "hitchance")+((getItemAttribute(itemEx.uid, "hitchance")/100)*config.upgradePercent))+1)
end
else
doPlayerSendTextMessage(cid, 22, getItemNameById(itemEx.itemid).." upgrading to level " .. (getUpgraded+1) .. " fail! You lose item!")
doRemoveItem(itemEx.uid, 1)
doSendMagicEffect(toPosition, 34)
end
doRemoveItem(item.uid, 1)
else
doPlayerSendCancel(cid, "You cannot upgrade this item!")
end
end
else
doPlayerSendCancel(cid, "This item is already upgraded to maximum item level.")
end
return TRUE
end
Last edited: