• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Help me with this error on itemupgrade!

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,780
Solutions
31
Reaction score
2,299
Location
Sweden?
This is the error i get when i trying to upgrade items on tfs 0.3.6!

LUA:
[18/06/2012 10:59:18] [Error - Action Interface] 
[18/06/2012 10:59:18] data/actions/scripts/slot.lua:onUse
[18/06/2012 10:59:18] Description: 
[18/06/2012 10:59:18] (luaGetThing) Thing not found

[18/06/2012 10:59:18] [Error - Action Interface] 
[18/06/2012 10:59:18] data/actions/scripts/slot.lua:onUse
[18/06/2012 10:59:18] Description: 
[18/06/2012 10:59:18] data/lib/050-function.lua:279: attempt to index a boolean value
[18/06/2012 10:59:18] stack traceback:
[18/06/2012 10:59:18] 	data/lib/050-function.lua:279: in function 'getItemName'
[18/06/2012 10:59:18] 	data/actions/scripts/slot.lua:24: in function 'getItemInfo'
[18/06/2012 10:59:18] 	data/lib/050-function.lua:572: in function 'getItemDescriptions'
[18/06/2012 10:59:18] 	data/lib/050-function.lua:279: in function 'getItemName'
[18/06/2012 10:59:18] 	data/actions/scripts/slot.lua:24: in function 'getItemInfo'
[18/06/2012 10:59:18] 	data/actions/scripts/slot.lua:53: in function <data/actions/scripts/slot.lua:50>

LUA:
 local conf = {}
 
 
-- // config // --
conf.maxItemLevel = 10 -- max item level 
conf.successChance = 50  -- succes upgrade chance
 
conf["upgrade"] = { -- how many parcent attributes are rised?
    attack = 5, -- attack %
    extraAttack = 10, -- extra Attack %
    defence = 5, -- defence %
    extraDefence = 10, -- extra defence %
    armor = 5, -- armor %
    attackSpeed = 3, -- attack speed %
    hitChance = 5, -- hit chance %
    shootRange = 2, -- shoot range %
}
 
--// end // --
 
function getItemInfo(item)
 
    local attr = {}
    local name = string.explode(getItemName(item), '+');
    if #name == 1 then
        attr.name = name[1]
        attr.level = math.abs(0)
    else
        attr.level = math.abs(name[2])
        attr.name = name[1]
    end
        attr.attack = (getItemAttack(item) > 0) and getItemAttack(item) or 0
        attr.extraAttack = (getItemExtraAttack(item) > 0) and getItemExtraAttack(item) or 0
        attr.defence = (getItemDefense(item) > 0) and getItemDefense(item) or 0
        attr.extraDefence = (getItemExtraDefense(item) > 0) and getItemExtraDefense(item) or 0
        attr.armor = (getItemArmor(item) > 0) and getItemArmor(item) or 0
        attr.attackSpeed = (getItemAttackSpeed(item) > 0) and getItemAttackSpeed(item) or 0
        attr.hitChance = (getItemHitChance(item) > 0) and getItemHitChance(item) or 0
        attr.shootRange = (getItemShootRange(item) > 0) and getItemShootRange(item) or 0
        attr.weight = (getItemWeight(item) > 0) and getItemWeight(item) or 0
 
    return attr
end
 
function upgradeValue(value, parcent)
    local newValue = math.ceil(((value/100)*parcent)+value)
    return (newValue > 0) and newValue or 0
end
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
    if toPosition.x == 65535 then
        local upgradingItem = getItemInfo(itemEx.uid)
        if (upgradingItem.attack > 0 or upgradingItem.defence > 0 or upgradingItem.armor > 0 or upgradingItem.shootRange > 1) then
            if (upgradingItem.level < conf.maxItemLevel) then
                if conf.successChance >= math.random(1,100) then
                    setItemName(itemEx.uid, upgradingItem.name.." + "..(upgradingItem.level+1))
                    setItemAttack(itemEx.uid, upgradeValue(upgradingItem.attack, conf["upgrade"].attack))
                    setItemExtraAttack(itemEx.uid, upgradeValue(upgradingItem.extraAttack, conf["upgrade"].extraAttack))
                    setItemDefense(itemEx.uid, upgradeValue(upgradingItem.defence, conf["upgrade"].defence))
                    setItemExtraDefense(itemEx.uid, upgradeValue(upgradingItem.extraDefence, conf["upgrade"].extraDefence))
                    setItemArmor(itemEx.uid, upgradeValue(upgradingItem.armor, conf["upgrade"].armor))
                    setItemAttackSpeed(itemEx.uid, upgradeValue(upgradingItem.attackSpeed, conf["upgrade"].attackSpeed))
                    setItemHitChance(itemEx.uid, upgradeValue(upgradingItem.hitChance, conf["upgrade"].hitChance))
                    setItemShootRange(itemEx.uid, upgradeValue(upgradingItem.shootRange, conf["upgrade"].shootRange))
                    doSendMagicEffect(toPosition, 30)
                    doPlayerSendTextMessage(cid, 22, "Upgraded was successful, your item has become stronger!")
                else
                    doRemoveItem(itemEx.uid, itemEx.type)
                    doSendMagicEffect(toPosition, 2)
                    doPlayerSendTextMessage(cid, 22, "Upgrading fail... you lost upgraded item!")
                end
                doRemoveItem(item.uid, 1)
            else
                doPlayerSendCancel(cid, "This item is on max level!")
            end
        else
            doPlayerSendCancel(cid, "You cannot upgrade this item!")
        end
    else
        doPlayerSendCancel(cid, "You can upgrading items only in inventory!")
    end
    return TRUE;
end

rep will be earned!
 
i found same script somwhere maybe this this 1
LUA:
 local conf = {}
 
 
-- // config // --
conf.maxItemLevel = 10 -- max item level 
conf.successChance = 50 -- succes upgrade chance
 
conf["upgrade"] = { -- how many parcent attributes are rised?
    attack = 5, -- attack %
    extraAttack = 10, -- extra Attack %
    defence = 5, -- defence %
    extraDefence = 10, -- extra defence %
    armor = 5, -- armor %
    attackSpeed = 3, -- attack speed %
    hitChance = 5, -- hit chance %
    shootRange = 2, -- shoot range %
}
 
--// end // --
 
function getItemInfo(item)
 
    local attr = {}
    if #name == 1 then
        attr.name = name[1]
        attr.level = math.abs(0)
    else
        attr.level = math.abs(name[2])
        attr.name = name[1]
    end
        attr.attack = (getItemAttack(item) > 0) and getItemAttack(item) or 0
        attr.extraAttack = (getItemExtraAttack(item) > 0) and getItemExtraAttack(item) or 0
        attr.defence = (getItemDefense(item) > 0) and getItemDefense(item) or 0
        attr.extraDefence = (getItemExtraDefense(item) > 0) and getItemExtraDefense(item) or 0
        attr.armor = (getItemArmor(item) > 0) and getItemArmor(item) or 0
        attr.attackSpeed = (getItemAttackSpeed(item) > 0) and getItemAttackSpeed(item) or 0
        attr.hitChance = (getItemHitChance(item) > 0) and getItemHitChance(item) or 0
        attr.shootRange = (getItemShootRange(item) > 0) and getItemShootRange(item) or 0
        attr.weight = (getItemWeight(item) > 0) and getItemWeight(item) or 0
 
    return attr
end
 
function upgradeValue(value, parcent)
    local newValue = math.ceil(((value/100)*parcent)+value)
    return (newValue > 0) and newValue or 0
end
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
    if toPosition.x == 65535 then
        local upgradingItem = getItemInfo(itemEx.uid)
            if (upgradingItem.level < conf.maxItemLevel) then
                if conf.successChance >= math.random(1,100) then
                    setItemName(itemEx.uid, upgradingItem.name.." + "..(upgradingItem.level+1))
                    setItemAttack(itemEx.uid, upgradeValue(upgradingItem.attack, conf["upgrade"].attack))
                    setItemExtraAttack(itemEx.uid, upgradeValue(upgradingItem.extraAttack, conf["upgrade"].extraAttack))
                    setItemDefense(itemEx.uid, upgradeValue(upgradingItem.defence, conf["upgrade"].defence))
                    setItemExtraDefense(itemEx.uid, upgradeValue(upgradingItem.extraDefence, conf["upgrade"].extraDefence))
                    setItemArmor(itemEx.uid, upgradeValue(upgradingItem.armor, conf["upgrade"].armor))
                    setItemAttackSpeed(itemEx.uid, upgradeValue(upgradingItem.attackSpeed, conf["upgrade"].attackSpeed))
                    setItemHitChance(itemEx.uid, upgradeValue(upgradingItem.hitChance, conf["upgrade"].hitChance))
                    setItemShootRange(itemEx.uid, upgradeValue(upgradingItem.shootRange, conf["upgrade"].shootRange))
                    doSendMagicEffect(toPosition, 30)
                    doPlayerSendTextMessage(cid, 22, "Upgraded was successful, your item has become stronger!")
                else
                    doRemoveItem(itemEx.uid, itemEx.type)
                    doSendMagicEffect(toPosition, 2)
                    doPlayerSendTextMessage(cid, 22, "Upgrading fail... you lost upgraded item!")
                end
                doRemoveItem(item.uid, 1)
            else
                doPlayerSendCancel(cid, "This item is on max level!")
            end
        else
            doPlayerSendCancel(cid, "You cannot upgrade this item!")
        end
    else
        doPlayerSendCancel(cid, "You can upgrading items only in inventory!")
    end
    return TRUE
end
 
Back
Top