• 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:
It works but also send mi this msg and the item dont disappear.

[13/01/2010 13:18:48] [Error - Action Interface]
[13/01/2010 13:18:48] data/actions/scripts/other/upgrade.lua:eek:nUse
[13/01/2010 13:18:48] Description:
[13/01/2010 13:18:48] data/actions/scripts/other/upgrade.lua:23: attempt to compare number with nil
[13/01/2010 13:18:48] stack traceback:
[13/01/2010 13:18:48] data/actions/scripts/other/upgrade.lua:23: in function <data/actions/scripts/other/upgrade.lua:10>
 
Code:
--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.

local 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) and not isItemRune(itemEx.itemid) and not isCorpse(itemEx.uid) and not isContainer(itemEx.uid)and not isItemStackable(itemEx.itemid) and not isItemFluidContainer(itemEx.itemid) and not isInArray(config.notAllowed, itemEx.itemid) then
				if config.brokeChance <= math.random(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
getItemAttribute returns nil if the attribute isn't present, so you first have to check if it returned true (not nil or false), and then compare it with a number ;)
 
Code:
--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.

local 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) and not isItemRune(itemEx.itemid) and not isCorpse(itemEx.uid) and not isContainer(itemEx.uid)and not isItemStackable(itemEx.itemid) and not isItemFluidContainer(itemEx.itemid) and not isInArray(config.notAllowed, itemEx.itemid) then
				if config.brokeChance <= math.random(100) then
					doItemSetAttribute(itemEx.uid, "name", getItemNameById(itemEx.itemid) .. "+" .. (getUpgraded+1))
					doItemSetAttribute(itemEx.uid, "aid", 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
That works good with "+", but don't adding atk/def etc. :/
 
hmm, something is wrong with new attribute system
when I use it normally it does nothing, but when I change ingame attach of weapon to even the same it upgrades ; o

or I dunno, now I lowered upgradepercent and nothing happens ;d
 
just change all the getItemAttribute(itemEx.uid, somekindofattributehere) to tostring(getItemAttribute(itemEx.uid, somekindofattributehere))
 
Edit,I changed this what y say and I have one error
[19/01/2010 20:04:26] [Error - Action Interface]
[19/01/2010 20:04:26] data/actions/scripts/upgrade.lua:eek:nUse
[19/01/2010 20:04:26] Description:
[19/01/2010 20:04:26] data/actions/scripts/upgrade.lua:23: attempt to compare number with string
[19/01/2010 20:04:26] stack traceback:
[19/01/2010 20:04:26] data/actions/scripts/upgrade.lua:23: in function <data/actions/scripts/upgrade.lua:10>
 
We can't doshort this script? When Item1 can give only attack to weapon?

function onUse(cid, item, frompos, item2, topos)
local how much = 1
local arm = getItemArmor(item2.uid)
if item2.uid ~=0 then
descr = "Values: "
if(arm ~= 0) then
setItemArmor(item2.uid, arm + how much)
doSendMagicEffect(topos,CONST_ME_MAGIC_BLUE)
doRemoveItem(item.uid,1)
else
doPlayerSendCancel(cid,"You can't upgrade this.")
end
return TRUE
end
return FALSE
end
 
Refresh.. i too need to fix this script. I need it to ots, but this is bad working ... only changing item to item+1, item+2...
Atack and def still normal.

Sorry for bad english
 
Back
Top