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

Lua Error in script upgrade

daiver

New Member
Joined
Oct 22, 2008
Messages
22
Reaction score
3
Good, greetings to the whole community ...
I'm editing a server which is otx 2 Final version, based on TFS 0.3.7.
you add a system upgrade that is to that version, the console reads normally worse, using the upgrade stone throws me the following error in console ...


Code:
[Error - Action Interface]
data/actions/scripts/items/upgrading.lua:onUse
Description:
data/actions/scripts/items/upgrading.lua:51: attempt to compare number with nil
stack traceback:
data/actions/scripts/items/upgrading.lua:51: in function <data/actions/scripts/items/upgrading.lua:46>

I could not know why the mistake, everyone will work least to me, here I leave the scrip in case I want to help with that line ...

Code:
local conf = {}

conf["level"] = {
-- [item_level] = {successParcent=PARCENT FOR UPGRADING SUCCESS, downrageLevel = IF UPGRADING FAIL - ITEM WAS DECRASED TO LEVEL HERE}
    [1] = {successPercent = 80, downgradeLevel = 1},
    [2] = {successPercent = 60, downgradeLevel = 2},
    [3] = {successPercent = 40, downgradeLevel = 2},
    [4] = {successPercent = 30, downgradeLevel = 0},
    [5] = {successPercent = 20, downgradeLevel = 0},
    [6] = {successPercent = 10, downgradeLevel = 0},
    [7] = {successPercent = 5, downgradeLevel = 0},
    [8] = {successPercent = 4, downgradeLevel = 0},
    [9] = {successPercent = 3, downgradeLevel = 0},
    [10] = {successPercent = 3, downgradeLevel = 0},
    [11] = {successPercent = 2, downgradeLevel = 0},
    [12] = {successPercent = 2, downgradeLevel = 0},
    [13] = {successPercent = 1, downgradeLevel = 0},
    [14] = {successPercent = 1, downgradeLevel = 0},
    [15] = {successPercent = 1, downgradeLevel = 0}
}
conf["upgrade"] = { -- how many parcent attributes are rised?
    attack = 5, -- attack %
    extraAttack = 10, -- extra Attack %
    defense = 5, -- defence %
    extraDefense = 10, -- extra defence %
    armor = 5, -- armor %
    hitChance = 5, -- hit chance %
}

-- // do not touch // --
-- Upgrading system v.3.1 by Azi [Ersiu] --
local upgrading = {
    upValue = function (value, level, parcent)
        if(not(value>0))then return 0 end
        for i=1,level do
            value = math.ceil(((value/100)*parcent)+value)+1
        end
        return (value > 0) and value or 0
    end,

    getLevel = function (item)
        local name = string.explode(getItemName(item), '+')
        return (#name == 1) and 0 or math.abs(name[2])
    end,
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local getItem = getItemInfo(itemEx.itemid)
    if((getItem.weaponType > 0 or getItem.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)].successParcent >= math.random(1,100)) and (level+1) or conf["level"][level].downrageLevel
            if(nLevel > level)then
                doSendMagicEffect(toPosition, 30)
                doPlayerSendTextMessage(cid, 22, "Congratz! Upgraded was successful, your item has become stronger!")
            else
                doSendMagicEffect(toPosition, 2)
                doPlayerSendTextMessage(cid, 22, "Argh! Upgrading fail... you item lost some of strong!")
            end
            doItemSetAttribute(itemEx.uid, "name", getItem.name..((nLevel>0) and "+"..nLevel or ""))
            doItemSetAttribute(itemEx.uid, "attack",  upgrading.upValue(getItem.attack, nLevel, conf["upgrade"].attack))
            doItemSetAttribute(itemEx.uid, "extraattack", upgrading.upValue(getItem.extraAttack, nLevel, conf["upgrade"].extraAttack))
            doItemSetAttribute(itemEx.uid, "defense", upgrading.upValue(getItem.defense,nLevel, conf["upgrade"].defense))
            doItemSetAttribute(itemEx.uid, "extradefense", upgrading.upValue(getItem.extraDefense, nLevel, conf["upgrade"].extraDefense))
            doItemSetAttribute(itemEx.uid, "armor", upgrading.upValue(getItem.armor, nLevel, conf["upgrade"].armor))
            doItemSetAttribute(itemEx.uid, "hitChance", upgrading.upValue(getItem.hitChance,nLevel, conf["upgrade"].hitChance))
            doRemoveItem(item.uid, 1)
        else
            doPlayerSendTextMessage(cid, 19, "Sorry this item is on max level.")
        end
    else
        doPlayerSendTextMessage(cid, 19, "You cannot upgrade this item.")
    end
end

The script is out of this post
https://otland.net/threads/items-upgrading-by-jewels-ver-3-for-tfs-0-3-6.79098/

In advance thank you ... Greetings and sorry for my english
 
Good, greetings to the whole community ...
I'm editing a server which is otx 2 Final version, based on TFS 0.3.7.
you add a system upgrade that is to that version, the console reads normally worse, using the upgrade stone throws me the following error in console ...


Code:
[Error - Action Interface]
data/actions/scripts/items/upgrading.lua:onUse
Description:
data/actions/scripts/items/upgrading.lua:51: attempt to compare number with nil
stack traceback:
data/actions/scripts/items/upgrading.lua:51: in function <data/actions/scripts/items/upgrading.lua:46>

I could not know why the mistake, everyone will work least to me, here I leave the scrip in case I want to help with that line ...

Code:
local conf = {}

conf["level"] = {
-- [item_level] = {successParcent=PARCENT FOR UPGRADING SUCCESS, downrageLevel = IF UPGRADING FAIL - ITEM WAS DECRASED TO LEVEL HERE}
    [1] = {successPercent = 80, downgradeLevel = 1},
    [2] = {successPercent = 60, downgradeLevel = 2},
    [3] = {successPercent = 40, downgradeLevel = 2},
    [4] = {successPercent = 30, downgradeLevel = 0},
    [5] = {successPercent = 20, downgradeLevel = 0},
    [6] = {successPercent = 10, downgradeLevel = 0},
    [7] = {successPercent = 5, downgradeLevel = 0},
    [8] = {successPercent = 4, downgradeLevel = 0},
    [9] = {successPercent = 3, downgradeLevel = 0},
    [10] = {successPercent = 3, downgradeLevel = 0},
    [11] = {successPercent = 2, downgradeLevel = 0},
    [12] = {successPercent = 2, downgradeLevel = 0},
    [13] = {successPercent = 1, downgradeLevel = 0},
    [14] = {successPercent = 1, downgradeLevel = 0},
    [15] = {successPercent = 1, downgradeLevel = 0}
}
conf["upgrade"] = { -- how many parcent attributes are rised?
    attack = 5, -- attack %
    extraAttack = 10, -- extra Attack %
    defense = 5, -- defence %
    extraDefense = 10, -- extra defence %
    armor = 5, -- armor %
    hitChance = 5, -- hit chance %
}

-- // do not touch // --
-- Upgrading system v.3.1 by Azi [Ersiu] --
local upgrading = {
    upValue = function (value, level, parcent)
        if(not(value>0))then return 0 end
        for i=1,level do
            value = math.ceil(((value/100)*parcent)+value)+1
        end
        return (value > 0) and value or 0
    end,

    getLevel = function (item)
        local name = string.explode(getItemName(item), '+')
        return (#name == 1) and 0 or math.abs(name[2])
    end,
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local getItem = getItemInfo(itemEx.itemid)
    if((getItem.weaponType > 0 or getItem.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)].successParcent >= math.random(1,100)) and (level+1) or conf["level"][level].downrageLevel
            if(nLevel > level)then
                doSendMagicEffect(toPosition, 30)
                doPlayerSendTextMessage(cid, 22, "Congratz! Upgraded was successful, your item has become stronger!")
            else
                doSendMagicEffect(toPosition, 2)
                doPlayerSendTextMessage(cid, 22, "Argh! Upgrading fail... you item lost some of strong!")
            end
            doItemSetAttribute(itemEx.uid, "name", getItem.name..((nLevel>0) and "+"..nLevel or ""))
            doItemSetAttribute(itemEx.uid, "attack",  upgrading.upValue(getItem.attack, nLevel, conf["upgrade"].attack))
            doItemSetAttribute(itemEx.uid, "extraattack", upgrading.upValue(getItem.extraAttack, nLevel, conf["upgrade"].extraAttack))
            doItemSetAttribute(itemEx.uid, "defense", upgrading.upValue(getItem.defense,nLevel, conf["upgrade"].defense))
            doItemSetAttribute(itemEx.uid, "extradefense", upgrading.upValue(getItem.extraDefense, nLevel, conf["upgrade"].extraDefense))
            doItemSetAttribute(itemEx.uid, "armor", upgrading.upValue(getItem.armor, nLevel, conf["upgrade"].armor))
            doItemSetAttribute(itemEx.uid, "hitChance", upgrading.upValue(getItem.hitChance,nLevel, conf["upgrade"].hitChance))
            doRemoveItem(item.uid, 1)
        else
            doPlayerSendTextMessage(cid, 19, "Sorry this item is on max level.")
        end
    else
        doPlayerSendTextMessage(cid, 19, "You cannot upgrade this item.")
    end
end

The script is out of this post
https://otland.net/threads/items-upgrading-by-jewels-ver-3-for-tfs-0-3-6.79098/

In advance thank you ... Greetings and sorry for my english

I dont know if it will solve your problem, but remove the last ' , ' on this part:

Code:
conf["upgrade"] = { -- how many parcent attributes are rised?
    attack = 5, -- attack %
    extraAttack = 10, -- extra Attack %
    defense = 5, -- defence %
    extraDefense = 10, -- extra defence %
    armor = 5, -- armor %
    hitChance = 5, -- hit chance %

And put this way:
Code:
conf["upgrade"] = { -- how many parcent attributes are rised?
    attack = 5, -- attack %
    extraAttack = 10, -- extra Attack %
    defense = 5, -- defence %
    extraDefense = 10, -- extra defence %
    armor = 5, -- armor %
    hitChance = 5 -- hit chance %
 
I dont know if it will solve your problem, but remove the last ' , ' on this part:

Code:
conf["upgrade"] = { -- how many parcent attributes are rised?
    attack = 5, -- attack %
    extraAttack = 10, -- extra Attack %
    defense = 5, -- defence %
    extraDefense = 10, -- extra defence %
    armor = 5, -- armor %
    hitChance = 5, -- hit chance %

And put this way:
Code:
conf["upgrade"] = { -- how many parcent attributes are rised?
    attack = 5, -- attack %
    extraAttack = 10, -- extra Attack %
    defense = 5, -- defence %
    extraDefense = 10, -- extra defence %
    armor = 5, -- armor %
    hitChance = 5 -- hit chance %
unrelated, having a comma on the last element of a table will not break anything.

@topic
Code:
local nLevel = (conf["level"][(level+1)].successParcent >= math.random(1,100)) and (level+1) or conf["level"][level].downrageLevel
change to
Code:
local nLevel = (conf["level"][(level+1)].successParcent >= math.random(1,100)) and (level+1) or conf["level"][level].downgradeLevel
the guy who made it is definitely not english, but he tried to use english words and failed.
 
unrelated, having a comma on the last element of a table will not break anything.

@topic
Code:
local nLevel = (conf["level"][(level+1)].successParcent >= math.random(1,100)) and (level+1) or conf["level"][level].downrageLevel
change to
Code:
local nLevel = (conf["level"][(level+1)].successParcent >= math.random(1,100)) and (level+1) or conf["level"][level].downgradeLevel
the guy who made it is definitely not english, but he tried to use english words and failed.

thank you very much man, if you do not show me that line had not found the error was successPercent and was successParcent .... thx problem solved, I'm Spanish so I do not copy anything right the English :(
 
Back
Top