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

Upgrade Items for TFS 0.3.6

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:
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
Let's solve this now :D!
 
Last edited:
Well, I can say that those needed functions are fine. The point is - admins of bigger servers wouldn't release script that makes nice money for them. So far I need just one more function to do, to make it work.

If you are scripter and you know how LUA works, you shall search for Collandus' execute lua function, and then try to play with functions that Elf gave me, here:
http://otland.net/663475-post10.html

The worst part is the one with item name, as not everyone knows string functions. But:
lua-users wiki: Search for: String Library Tutorial
(patterns tutorial and strings tutorial)

Best regards,
Hermes

PS. Well, if I finish this then I might release it.
 
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:
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
Let's solve this now :D!

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") and 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") and 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") and 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") and 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") and 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") and 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") and 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
 
bleh, backwards compatibility is useless here because it won't work on TFS 0.2 either way, so why use == FALSE and return TRUE?
also your config is global
and math.random(100) is the same as math.random(1, 100)
 
Back
Top