Ir para conteúdo
  • Cadastre-se

Normal Trocar +1,+2,+3 por nomes nesse script refin [10 reps]


Posts Recomendados

Alguém poderia fazer isso pra mim? Mexer no meu sistema de refinamento trocar onde fica:

23:43 You see a katana +1 (Atk:19, Def:14 +1). It weighs 31.00 oz.

 

Por

23:43 You see a unc katana (Atk:19, Def:14 +1). It weighs 31.00 oz.

 

No caso só vai até +3, queria que muda-se por nome... Exemplo:
+1 = unc
+2 = rare
+3 = epic

 

Alguém poderia fazer isso p mim?

 



    --PERFECT UPGRADE SYSTEM

    UpgradeHandler = {
        levels = {
              [1] = {50, false, false},
              [2] = {20, false, false},
              [3] = {10, true, true}
        },
        broadcast = 3,
        attributes = {
              ["attack"] = 3,
              ["defense"] = 2,
              ["armor"] = 1
        },
        message = {
              console = "Trying to refine %s to level +%s with %s%% success rate.",
              success = "You have upgraded %s to level +%s",
              fail = "You have failed in upgrade of %s to level +%s",
              downgrade = "The upgrade level of %s has downgraded to +%s",
              erase = "The upgrade level of %s has been erased.",
              maxlevel = "The targeted %s is already on max upgrade level.",
              notupgradeable = "This item is not upgradeable.",
              broadcast = "The player %s was successful in upgrading %s to level +%s.\nCongratulations!!",
              invalidtool = "This is not a valid upgrade tool.",
              toolrange = "This upgrade tool can only be used in items with level between +%s and +%s"
        },
        tools = {
            [8306] = {range = {0, 10}, info = {chance = 0, removeable = true}},
            [8300] = {range = {0, 10}, info = {chance = 0, removeable = true}}
        },
        isEquipment = function(self)
            local weaponType = self:getItemWeaponType()
            return ((weaponType > 0 and weaponType < 7) or self.item.armor ~= 0)
        end,
        setItemName = function(self, name)
            return doItemSetAttribute(self.item.uid, "name", name)
        end,
        chance = function(self)
            local chances = {}
            chances.upgrade = (self.levels[self.item.level + 1][1] or 100)
            chances.downgrade = (self.item.level * 5)
            chances.erase = (self.item.level * 3)
            return chances
        end
    }

    function UpgradeHandler:new(item)
        local obj, ret = {}
        obj.item = {}
        obj.item.level = 0
        obj.item.uid = item.uid
        for key, value in pairs(getItemInfo(item.itemid)) do
            obj.item[key] = value
        end
        ret = setmetatable(obj, {
            __index = function(self, index)
                if _G[index] then
                    return (setmetatable({callback = _G[index]},
                        {__call = function(self, ...)
                            return self.callback(item.uid, ...)
                        end}
                    ))
                else
                    return UpgradeHandler[index]
                end
        end})

        if ret:isEquipment() then
            ret:update()
            return ret
        end
        return false
    end

    function UpgradeHandler:update()
       -- this will return any number that has a + sign in front of it or 0 if there is no number with a + sign
        self.item.level = (tonumber(self:getItemName():match("%+(%d+)")) or 0)
    end

    function UpgradeHandler:refine(uid, item)
        if not self.item then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.notupgradeable)
            return "miss"
        end

        local tool = self.tools[item.itemid]
        if(tool == nil) then
            doPlayerSendTextMessage(uid, MESSAGE_EVENT_DEFAULT, self.message.invalidtool)
            return "miss"
        end

        if(self.item.level > #self.levels) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.maxlevel:format(self.item.name))
            return "miss"
        end

        if(self.item.level < tool.range[1] or self.item.level >= tool.range[2]) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.toolrange:format(unpack(tool.range)))
            return "miss"
        end

        local chance = (self:chance().upgrade + tool.info.chance)
        doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.console:format(self.item.name, (self.item.level + 1), math.min(100, chance)))
        if(tool.info.removeable == true) then
            doRemoveItem(item.uid, 1)
        end

        if chance * 100 > math.random(1, 10000) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1)))
            if (self.item.level + 1) >= self.broadcast then
                doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1)))
            end
            -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
            -- if the current level equals 0 add 1 to it
            self:setItemName((self.item.level > 0 and self:getItemName():gsub("%+(%d+)", "+".. (self.item.level + 1)) or (self:getItemName() .." +1")))
            for key, value in pairs(self.attributes) do
                if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                    doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value)
                end
            end
            return "success"
        else
            if item.itemid == 8300 then
                if self.item.level > 0 then
                    -- this will remove any number with a + sign in front of it from the string
                    self:setItemName(self:getItemName():gsub("(%s+)%+(%d+)", ""))
                    for key, value in pairs(self.attributes) do
                        if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                            doItemSetAttribute(self.item.uid, key, getItemAttribute(self.item.uid, key) - self.item.level * value)
                        end
                    end
                end
            else
                doRemoveItem(self.item.uid, 1)
            end
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, item.itemid == 8300 and "Your item level has been reseted." or "You have broken your item while trying to upgrade it.")
        end
    end

 

 

 

Pensei ser algo aqui:



self:setItemName(self:getItemName():gsub("(%s+)%+(%d+)", ""))

 

Mas não sei criar os ifs, não sei fazer :(

Link para o post
Compartilhar em outros sites
self.item.level = (tonumber(self:getItemName():match("%+(%d+)")) or 0)

aqui ele define ql é o level do item, vc tem que modificar isso de forma a fazer ele entender que RARE, UNQ, EPIC são leveis referentes a 1, 2, 3;

O resto é modificador os 
 

            -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
            -- if the current level equals 0 add 1 to it
            self:setItemName((self.item.level > 0 and self:getItemName():gsub("%+(%d+)", "+".. (self.item.level + 1)) or (self:getItemName() .." +1")))


-- this will remove any number with a + sign in front of it from the string
                    self:setItemName(self:getItemName():gsub("(%s+)%+(%d+)", ""))

 


Pra em vez de setar nome +Level no nome, setar a rarity + nome.

 

 

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

Link para o post
Compartilhar em outros sites
3 horas atrás, xWhiteWolf disse:

self.item.level = (tonumber(self:getItemName():match("%+(%d+)")) or 0)

aqui ele define ql é o level do item, vc tem que modificar isso de forma a fazer ele entender que RARE, UNQ, EPIC são leveis referentes a 1, 2, 3;

O resto é modificador os 
 


            -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
            -- if the current level equals 0 add 1 to it
            self:setItemName((self.item.level > 0 and self:getItemName():gsub("%+(%d+)", "+".. (self.item.level + 1)) or (self:getItemName() .." +1")))


-- this will remove any number with a + sign in front of it from the string
                    self:setItemName(self:getItemName():gsub("(%s+)%+(%d+)", ""))

 


Pra em vez de setar nome +Level no nome, setar a rarity + nome.

 

 

 

Mds mano que complicado!!! To tentando, mas não to conseguindo

 

Não tem como deixar ele setar o lvl +1,+2,+3 e fazer uma função que quando der look cheque o nivel

if(nivel == 1) setarnome ="unc"

elseif(nivel == 2) setarnome ="rare"

elseif(nivel == 3) setarnome ="epic"

Link para o post
Compartilhar em outros sites

testa assim
 

--PERFECT UPGRADE SYSTEM

    UpgradeHandler = {
		nameLv = {
		    ["UNIQ"] = 1,
		    ["RARE"] = 2,
		    ["EPIC"] = 3
	    }
        levels = {
              [1] = {50, false, false},
              [2] = {20, false, false},
              [3] = {10, true, true}
        },
        broadcast = 3,
        attributes = {
              ["attack"] = 3,
              ["defense"] = 2,
              ["armor"] = 1
        },
        message = {
              console = "Trying to refine %s to level +%s with %s%% success rate.",
              success = "You have upgraded %s to level +%s",
              fail = "You have failed in upgrade of %s to level +%s",
              downgrade = "The upgrade level of %s has downgraded to +%s",
              erase = "The upgrade level of %s has been erased.",
              maxlevel = "The targeted %s is already on max upgrade level.",
              notupgradeable = "This item is not upgradeable.",
              broadcast = "The player %s was successful in upgrading %s to level +%s.\nCongratulations!!",
              invalidtool = "This is not a valid upgrade tool.",
              toolrange = "This upgrade tool can only be used in items with level between +%s and +%s"
        },
        tools = {
            [8306] = {range = {0, 10}, info = {chance = 0, removeable = true}},
            [8300] = {range = {0, 10}, info = {chance = 0, removeable = true}}
        },
        isEquipment = function(self)
            local weaponType = self:getItemWeaponType()
            return ((weaponType > 0 and weaponType < 7) or self.item.armor ~= 0)
        end,
        setItemName = function(self, name)
            return doItemSetAttribute(self.item.uid, "name", name)
        end,
        chance = function(self)
            local chances = {}
            chances.upgrade = (self.levels[self.item.level + 1][1] or 100)
            chances.downgrade = (self.item.level * 5)
            chances.erase = (self.item.level * 3)
            return chances
        end
    }

    function UpgradeHandler:new(item)
        local obj, ret = {}
        obj.item = {}
        obj.item.level = 0
        obj.item.uid = item.uid
        for key, value in pairs(getItemInfo(item.itemid)) do
            obj.item[key] = value
        end
        ret = setmetatable(obj, {
            __index = function(self, index)
                if _G[index] then
                    return (setmetatable({callback = _G[index]},
                        {__call = function(self, ...)
                            return self.callback(item.uid, ...)
                        end}
                    ))
                else
                    return UpgradeHandler[index]
                end
        end})

        if ret:isEquipment() then
            ret:update()
            return ret
        end
        return false
    end


    function UpgradeHandler:update()
       -- this will return the level by the quality or 0 if it has no quality.
        self.item.level = 0
		for r, v in ipairs(self.nameLv) do
		    if self:getItemName():find(r) then
		        self.item.level = v
		    end
		end
    end

    function UpgradeHandler:refine(uid, item)
        if not self.item then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.notupgradeable)
            return "miss"
        end

        local tool = self.tools[item.itemid]
        if(tool == nil) then
            doPlayerSendTextMessage(uid, MESSAGE_EVENT_DEFAULT, self.message.invalidtool)
            return "miss"
        end

        if(self.item.level > #self.levels) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.maxlevel:format(self.item.name))
            return "miss"
        end

        if(self.item.level < tool.range[1] or self.item.level >= tool.range[2]) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.toolrange:format(unpack(tool.range)))
            return "miss"
        end

        local chance = (self:chance().upgrade + tool.info.chance)
        doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.console:format(self.item.name, (self.item.level + 1), math.min(100, chance)))
        if(tool.info.removeable == true) then
            doRemoveItem(item.uid, 1)
        end

        if chance * 100 > math.random(1, 10000) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1)))
            if (self.item.level + 1) >= self.broadcast then
                doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1)))
            end
            -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
            -- if the current level equals 0 add 1 to it
            self:setItemName(self.item.level > 0 and self.nameLv[self.item.level].." "..self:getItemName():gsub(self.nameLv[self.item.level].." ", "") or self.nameLv[1].." "..self:getItemName())
            for key, value in pairs(self.attributes) do
                if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                    doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value)
                end
            end
            return "success"
        else
            if item.itemid == 8300 then
                if self.item.level > 0 then
                    -- this will remove any number with a + sign in front of it from the string
                    self:setItemName(self:getItemName():gsub(self.nameLv[self.item.level].." ", ""))
                    for key, value in pairs(self.attributes) do
                        if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                            doItemSetAttribute(self.item.uid, key, getItemAttribute(self.item.uid, key) - self.item.level * value)
                        end
                    end
                end
            else
                doRemoveItem(self.item.uid, 1)
            end
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, item.itemid == 8300 and "Your item level has been reseted." or "You have broken your item while trying to upgrade it.")
        end
    end

 

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

Link para o post
Compartilhar em outros sites
7 horas atrás, xWhiteWolf disse:

testa assim
 


--PERFECT UPGRADE SYSTEM

    UpgradeHandler = {
		nameLv = {
		    ["UNIQ"] = 1,
		    ["RARE"] = 2,
		    ["EPIC"] = 3
	    }
        levels = {
              [1] = {50, false, false},
              [2] = {20, false, false},
              [3] = {10, true, true}
        },
        broadcast = 3,
        attributes = {
              ["attack"] = 3,
              ["defense"] = 2,
              ["armor"] = 1
        },
        message = {
              console = "Trying to refine %s to level +%s with %s%% success rate.",
              success = "You have upgraded %s to level +%s",
              fail = "You have failed in upgrade of %s to level +%s",
              downgrade = "The upgrade level of %s has downgraded to +%s",
              erase = "The upgrade level of %s has been erased.",
              maxlevel = "The targeted %s is already on max upgrade level.",
              notupgradeable = "This item is not upgradeable.",
              broadcast = "The player %s was successful in upgrading %s to level +%s.\nCongratulations!!",
              invalidtool = "This is not a valid upgrade tool.",
              toolrange = "This upgrade tool can only be used in items with level between +%s and +%s"
        },
        tools = {
            [8306] = {range = {0, 10}, info = {chance = 0, removeable = true}},
            [8300] = {range = {0, 10}, info = {chance = 0, removeable = true}}
        },
        isEquipment = function(self)
            local weaponType = self:getItemWeaponType()
            return ((weaponType > 0 and weaponType < 7) or self.item.armor ~= 0)
        end,
        setItemName = function(self, name)
            return doItemSetAttribute(self.item.uid, "name", name)
        end,
        chance = function(self)
            local chances = {}
            chances.upgrade = (self.levels[self.item.level + 1][1] or 100)
            chances.downgrade = (self.item.level * 5)
            chances.erase = (self.item.level * 3)
            return chances
        end
    }

    function UpgradeHandler:new(item)
        local obj, ret = {}
        obj.item = {}
        obj.item.level = 0
        obj.item.uid = item.uid
        for key, value in pairs(getItemInfo(item.itemid)) do
            obj.item[key] = value
        end
        ret = setmetatable(obj, {
            __index = function(self, index)
                if _G[index] then
                    return (setmetatable({callback = _G[index]},
                        {__call = function(self, ...)
                            return self.callback(item.uid, ...)
                        end}
                    ))
                else
                    return UpgradeHandler[index]
                end
        end})

        if ret:isEquipment() then
            ret:update()
            return ret
        end
        return false
    end


    function UpgradeHandler:update()
       -- this will return the level by the quality or 0 if it has no quality.
        self.item.level = 0
		for r, v in ipairs(self.nameLv) do
		    if self:getItemName():find(r) then
		        self.item.level = v
		    end
		end
    end

    function UpgradeHandler:refine(uid, item)
        if not self.item then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.notupgradeable)
            return "miss"
        end

        local tool = self.tools[item.itemid]
        if(tool == nil) then
            doPlayerSendTextMessage(uid, MESSAGE_EVENT_DEFAULT, self.message.invalidtool)
            return "miss"
        end

        if(self.item.level > #self.levels) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.maxlevel:format(self.item.name))
            return "miss"
        end

        if(self.item.level < tool.range[1] or self.item.level >= tool.range[2]) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.toolrange:format(unpack(tool.range)))
            return "miss"
        end

        local chance = (self:chance().upgrade + tool.info.chance)
        doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.console:format(self.item.name, (self.item.level + 1), math.min(100, chance)))
        if(tool.info.removeable == true) then
            doRemoveItem(item.uid, 1)
        end

        if chance * 100 > math.random(1, 10000) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1)))
            if (self.item.level + 1) >= self.broadcast then
                doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1)))
            end
            -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
            -- if the current level equals 0 add 1 to it
            self:setItemName(self.item.level > 0 and self.nameLv[self.item.level].." "..self:getItemName():gsub(self.nameLv[self.item.level].." ", "") or self.nameLv[1].." "..self:getItemName())
            for key, value in pairs(self.attributes) do
                if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                    doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value)
                end
            end
            return "success"
        else
            if item.itemid == 8300 then
                if self.item.level > 0 then
                    -- this will remove any number with a + sign in front of it from the string
                    self:setItemName(self:getItemName():gsub(self.nameLv[self.item.level].." ", ""))
                    for key, value in pairs(self.attributes) do
                        if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                            doItemSetAttribute(self.item.uid, key, getItemAttribute(self.item.uid, key) - self.item.level * value)
                        end
                    end
                end
            else
                doRemoveItem(self.item.uid, 1)
            end
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, item.itemid == 8300 and "Your item level has been reseted." or "You have broken your item while trying to upgrade it.")
        end
    end

Deu ruim total na hora de usar a pedra em uma arma, ta dando esses erros no console e na arma nada acontece:

http://imgur.com/vSR1gtp

Ah se esqueceu de por uma vírgula ali eu acho, não é querendo te corrigir é pq eu sou mt noob e posso ta fazendo merda xD

 



--PERFECT UPGRADE SYSTEM

    UpgradeHandler = {
        nameLv = {
            ["UNIQ"] = 1,
            ["RARE"] = 2,
            ["EPIC"] = 3
        },
        levels = {
              [1] = {50, false, false},
              [2] = {20, false, false},
              [3] = {10, true, true}
        },
        broadcast = 3,
        attributes = {
              ["attack"] = 3,
              ["defense"] = 2,
              ["armor"] = 1
        },
        message = {
              console = "Trying to refine %s to level +%s with %s%% success rate.",
              success = "You have upgraded %s to level +%s",
              fail = "You have failed in upgrade of %s to level +%s",
              downgrade = "The upgrade level of %s has downgraded to +%s",
              erase = "The upgrade level of %s has been erased.",
              maxlevel = "The targeted %s is already on max upgrade level.",
              notupgradeable = "This item is not upgradeable.",
              broadcast = "The player %s was successful in upgrading %s to level +%s.\nCongratulations!!",
              invalidtool = "This is not a valid upgrade tool.",
              toolrange = "This upgrade tool can only be used in items with level between +%s and +%s"
        },
        tools = {
            [8306] = {range = {0, 10}, info = {chance = 0, removeable = true}},
            [8300] = {range = {0, 10}, info = {chance = 0, removeable = true}}
        },
        isEquipment = function(self)
            local weaponType = self:getItemWeaponType()
            return ((weaponType > 0 and weaponType < 7) or self.item.armor ~= 0)
        end,
        setItemName = function(self, name)
            return doItemSetAttribute(self.item.uid, "name", name)
        end,
        chance = function(self)
            local chances = {}
            chances.upgrade = (self.levels[self.item.level + 1][1] or 100)
            chances.downgrade = (self.item.level * 5)
            chances.erase = (self.item.level * 3)
            return chances
        end
    }

    function UpgradeHandler:new(item)
        local obj, ret = {}
        obj.item = {}
        obj.item.level = 0
        obj.item.uid = item.uid
        for key, value in pairs(getItemInfo(item.itemid)) do
            obj.item[key] = value
        end
        ret = setmetatable(obj, {
            __index = function(self, index)
                if _G[index] then
                    return (setmetatable({callback = _G[index]},
                        {__call = function(self, ...)
                            return self.callback(item.uid, ...)
                        end}
                    ))
                else
                    return UpgradeHandler[index]
                end
        end})

        if ret:isEquipment() then
            ret:update()
            return ret
        end
        return false
    end


    function UpgradeHandler:update()
       -- this will return the level by the quality or 0 if it has no quality.
        self.item.level = 0
        for r, v in ipairs(self.nameLv) do
            if self:getItemName():find(r) then
                self.item.level = v
            end
        end
    end

    function UpgradeHandler:refine(uid, item)
        if not self.item then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.notupgradeable)
            return "miss"
        end

        local tool = self.tools[item.itemid]
        if(tool == nil) then
            doPlayerSendTextMessage(uid, MESSAGE_EVENT_DEFAULT, self.message.invalidtool)
            return "miss"
        end

        if(self.item.level > #self.levels) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.maxlevel:format(self.item.name))
            return "miss"
        end

        if(self.item.level < tool.range[1] or self.item.level >= tool.range[2]) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.toolrange:format(unpack(tool.range)))
            return "miss"
        end

        local chance = (self:chance().upgrade + tool.info.chance)
        doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.console:format(self.item.name, (self.item.level + 1), math.min(100, chance)))
        if(tool.info.removeable == true) then
            doRemoveItem(item.uid, 1)
        end

        if chance * 100 > math.random(1, 10000) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1)))
            if (self.item.level + 1) >= self.broadcast then
                doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1)))
            end
            -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
            -- if the current level equals 0 add 1 to it
            self:setItemName(self.item.level > 0 and self.nameLv[self.item.level].." "..self:getItemName():gsub(self.nameLv[self.item.level].." ", "") or self.nameLv[1].." "..self:getItemName())
            for key, value in pairs(self.attributes) do
                if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                    doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value)
                end
            end
            return "success"
        else
            if item.itemid == 8300 then
                if self.item.level > 0 then
                    -- this will remove any number with a + sign in front of it from the string
                    self:setItemName(self:getItemName():gsub(self.nameLv[self.item.level].." ", ""))
                    for key, value in pairs(self.attributes) do
                        if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                            doItemSetAttribute(self.item.uid, key, getItemAttribute(self.item.uid, key) - self.item.level * value)
                        end
                    end
                end
            else
                doRemoveItem(self.item.uid, 1)
            end
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, item.itemid == 8300 and "Your item level has been reseted." or "You have broken your item while trying to upgrade it.")
        end
    end

 

Editado por gmstrikker (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

sim, esqueci a virgula, não percebi que upgradeHandler era uma tabela AIHHEUIA botando ali funciona?

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

Link para o post
Compartilhar em outros sites
8 horas atrás, xWhiteWolf disse:

sim, esqueci a virgula, não percebi que upgradeHandler era uma tabela AIHHEUIA botando ali funciona?

 

Não funcionou mano, na hora de usar a pedra em uma arma da esse erro e nem refina nada


http://imgur.com/vSR1gtp

 

E parece q é na lib msm :(

 

data/actions/upgrade.lua

 

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if isCreature(itemEx.uid) then    
        return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    end

    local obj = UpgradeHandler:new(itemEx)

    if(obj == false) then
        return doPlayerSendCancel(cid, UpgradeHandler.message.notupgradeable)
    end

    local status = obj:refine(cid, item)
    if status == "success" then
        --doSendAnimatedText(toPosition, "Success!", COLOR_GREEN)
        doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
    elseif status == "fail" then
        --doSendAnimatedText(toPosition, "Fail!", COLOR_RED)
        doSendMagicEffect(toPosition, CONST_ME_POFF)
    else
        doSendMagicEffect(toPosition, CONST_ME_POFF)
    end
    return true
end






 

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if isCreature(itemEx.uid) then    
        return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    end

    local obj = UpgradeHandler:new(itemEx)

    if(obj == false) then
        return doPlayerSendCancel(cid, UpgradeHandler.message.notupgradeable)
    end

    local status = obj:refine(cid, item)
    if status == "success" then
        --doSendAnimatedText(toPosition, "Success!", COLOR_GREEN)
        doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
    elseif status == "fail" then
        --doSendAnimatedText(toPosition, "Fail!", COLOR_RED)
        doSendMagicEffect(toPosition, CONST_ME_POFF)
    else
        doSendMagicEffect(toPosition, CONST_ME_POFF)
    end
    return true
end






 

Editado por gmstrikker (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

cometi uma pequena gafe hahaha eu modifiquei o script e esqueci de modificar a tabela que eu havia criado

 

Spoiler

--PERFECT UPGRADE SYSTEM

    UpgradeHandler = {
		nameLv = {
		    [1] = "UNIQ",
		    [2] = "RARE",
		    [3] = "EPIC"
	    },
        levels = {
              [1] = {50, false, false},
              [2] = {20, false, false},
              [3] = {10, true, true}
        },
        broadcast = 3,
        attributes = {
              ["attack"] = 3,
              ["defense"] = 2,
              ["armor"] = 1
        },
        message = {
              console = "Trying to refine %s to level +%s with %s%% success rate.",
              success = "You have upgraded %s to level +%s",
              fail = "You have failed in upgrade of %s to level +%s",
              downgrade = "The upgrade level of %s has downgraded to +%s",
              erase = "The upgrade level of %s has been erased.",
              maxlevel = "The targeted %s is already on max upgrade level.",
              notupgradeable = "This item is not upgradeable.",
              broadcast = "The player %s was successful in upgrading %s to level +%s.\nCongratulations!!",
              invalidtool = "This is not a valid upgrade tool.",
              toolrange = "This upgrade tool can only be used in items with level between +%s and +%s"
        },
        tools = {
            [8306] = {range = {0, 10}, info = {chance = 0, removeable = true}},
            [8300] = {range = {0, 10}, info = {chance = 0, removeable = true}}
        },
        isEquipment = function(self)
            local weaponType = self:getItemWeaponType()
            return ((weaponType > 0 and weaponType < 7) or self.item.armor ~= 0)
        end,
        setItemName = function(self, name)
            return doItemSetAttribute(self.item.uid, "name", name)
        end,
        chance = function(self)
            local chances = {}
            chances.upgrade = (self.levels[self.item.level + 1][1] or 100)
            chances.downgrade = (self.item.level * 5)
            chances.erase = (self.item.level * 3)
            return chances
        end
    }

    function UpgradeHandler:new(item)
        local obj, ret = {}
        obj.item = {}
        obj.item.level = 0
        obj.item.uid = item.uid
        for key, value in pairs(getItemInfo(item.itemid)) do
            obj.item[key] = value
        end
        ret = setmetatable(obj, {
            __index = function(self, index)
                if _G[index] then
                    return (setmetatable({callback = _G[index]},
                        {__call = function(self, ...)
                            return self.callback(item.uid, ...)
                        end}
                    ))
                else
                    return UpgradeHandler[index]
                end
        end})

        if ret:isEquipment() then
            ret:update()
            return ret
        end
        return false
    end


    function UpgradeHandler:update()
       -- this will return the level by the quality or 0 if it has no quality.
        self.item.level = 0
		for r, v in ipairs(self.nameLv) do
		    if self:getItemName():find(v) then
		        self.item.level = r
		    end
		end
    end

    function UpgradeHandler:refine(uid, item)
        if not self.item then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.notupgradeable)
            return "miss"
        end

        local tool = self.tools[item.itemid]
        if(tool == nil) then
            doPlayerSendTextMessage(uid, MESSAGE_EVENT_DEFAULT, self.message.invalidtool)
            return "miss"
        end

        if(self.item.level > #self.levels) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.maxlevel:format(self.item.name))
            return "miss"
        end

        if(self.item.level < tool.range[1] or self.item.level >= tool.range[2]) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.toolrange:format(unpack(tool.range)))
            return "miss"
        end

        local chance = (self:chance().upgrade + tool.info.chance)
        doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.console:format(self.item.name, (self.item.level + 1), math.min(100, chance)))
        if(tool.info.removeable == true) then
            doRemoveItem(item.uid, 1)
        end

        if chance * 100 > math.random(1, 10000) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1)))
            if (self.item.level + 1) >= self.broadcast then
                doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1)))
            end
            -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
            -- if the current level equals 0 add 1 to it
            self.item.level > 0 and (self.nameLv[self.item.level].." "..self:getItemName()):gsub((self.nameLv[self.item.level].." "), "") or self.nameLv[1].." "..self:getItemName()
            for key, value in pairs(self.attributes) do
                if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                    doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value)
                end
            end
            return "success"
        else
            if item.itemid == 8300 then
                if self.item.level > 0 then
                    -- this will remove any number with a + sign in front of it from the string
                    self:setItemName(self:getItemName():gsub((self.nameLv[self.item.level].." "), ""))
                    for key, value in pairs(self.attributes) do
                        if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                            doItemSetAttribute(self.item.uid, key, getItemAttribute(self.item.uid, key) - self.item.level * value)
                        end
                    end
                end
            else
                doRemoveItem(self.item.uid, 1)
            end
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, item.itemid == 8300 and "Your item level has been reseted." or "You have broken your item while trying to upgrade it.")
        end
    end

 

 

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

Link para o post
Compartilhar em outros sites
Em 01/02/2016 15:09:40, xWhiteWolf disse:

cometi uma pequena gafe hahaha eu modifiquei o script e esqueci de modificar a tabela que eu havia criado

 

  Mostrar conteúdo oculto



--PERFECT UPGRADE SYSTEM

    UpgradeHandler = {
		nameLv = {
		    [1] = "UNIQ",
		    [2] = "RARE",
		    [3] = "EPIC"
	    },
        levels = {
              [1] = {50, false, false},
              [2] = {20, false, false},
              [3] = {10, true, true}
        },
        broadcast = 3,
        attributes = {
              ["attack"] = 3,
              ["defense"] = 2,
              ["armor"] = 1
        },
        message = {
              console = "Trying to refine %s to level +%s with %s%% success rate.",
              success = "You have upgraded %s to level +%s",
              fail = "You have failed in upgrade of %s to level +%s",
              downgrade = "The upgrade level of %s has downgraded to +%s",
              erase = "The upgrade level of %s has been erased.",
              maxlevel = "The targeted %s is already on max upgrade level.",
              notupgradeable = "This item is not upgradeable.",
              broadcast = "The player %s was successful in upgrading %s to level +%s.\nCongratulations!!",
              invalidtool = "This is not a valid upgrade tool.",
              toolrange = "This upgrade tool can only be used in items with level between +%s and +%s"
        },
        tools = {
            [8306] = {range = {0, 10}, info = {chance = 0, removeable = true}},
            [8300] = {range = {0, 10}, info = {chance = 0, removeable = true}}
        },
        isEquipment = function(self)
            local weaponType = self:getItemWeaponType()
            return ((weaponType > 0 and weaponType < 7) or self.item.armor ~= 0)
        end,
        setItemName = function(self, name)
            return doItemSetAttribute(self.item.uid, "name", name)
        end,
        chance = function(self)
            local chances = {}
            chances.upgrade = (self.levels[self.item.level + 1][1] or 100)
            chances.downgrade = (self.item.level * 5)
            chances.erase = (self.item.level * 3)
            return chances
        end
    }

    function UpgradeHandler:new(item)
        local obj, ret = {}
        obj.item = {}
        obj.item.level = 0
        obj.item.uid = item.uid
        for key, value in pairs(getItemInfo(item.itemid)) do
            obj.item[key] = value
        end
        ret = setmetatable(obj, {
            __index = function(self, index)
                if _G[index] then
                    return (setmetatable({callback = _G[index]},
                        {__call = function(self, ...)
                            return self.callback(item.uid, ...)
                        end}
                    ))
                else
                    return UpgradeHandler[index]
                end
        end})

        if ret:isEquipment() then
            ret:update()
            return ret
        end
        return false
    end


    function UpgradeHandler:update()
       -- this will return the level by the quality or 0 if it has no quality.
        self.item.level = 0
		for r, v in ipairs(self.nameLv) do
		    if self:getItemName():find(v) then
		        self.item.level = r
		    end
		end
    end

    function UpgradeHandler:refine(uid, item)
        if not self.item then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.notupgradeable)
            return "miss"
        end

        local tool = self.tools[item.itemid]
        if(tool == nil) then
            doPlayerSendTextMessage(uid, MESSAGE_EVENT_DEFAULT, self.message.invalidtool)
            return "miss"
        end

        if(self.item.level > #self.levels) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.maxlevel:format(self.item.name))
            return "miss"
        end

        if(self.item.level < tool.range[1] or self.item.level >= tool.range[2]) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.toolrange:format(unpack(tool.range)))
            return "miss"
        end

        local chance = (self:chance().upgrade + tool.info.chance)
        doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.console:format(self.item.name, (self.item.level + 1), math.min(100, chance)))
        if(tool.info.removeable == true) then
            doRemoveItem(item.uid, 1)
        end

        if chance * 100 > math.random(1, 10000) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1)))
            if (self.item.level + 1) >= self.broadcast then
                doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1)))
            end
            -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
            -- if the current level equals 0 add 1 to it
            self.item.level > 0 and (self.nameLv[self.item.level].." "..self:getItemName()):gsub((self.nameLv[self.item.level].." "), "") or self.nameLv[1].." "..self:getItemName()
            for key, value in pairs(self.attributes) do
                if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                    doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value)
                end
            end
            return "success"
        else
            if item.itemid == 8300 then
                if self.item.level > 0 then
                    -- this will remove any number with a + sign in front of it from the string
                    self:setItemName(self:getItemName():gsub((self.nameLv[self.item.level].." "), ""))
                    for key, value in pairs(self.attributes) do
                        if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                            doItemSetAttribute(self.item.uid, key, getItemAttribute(self.item.uid, key) - self.item.level * value)
                        end
                    end
                end
            else
                doRemoveItem(self.item.uid, 1)
            end
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, item.itemid == 8300 and "Your item level has been reseted." or "You have broken your item while trying to upgrade it.")
        end
    end

 

 

 

Deu uns erros na hora de abrir o sv

 

http://imgur.com/01TkKJ7

Link para o post
Compartilhar em outros sites

kct, to decepcionado cmg msmo AHUEUHA to esquecendo umas coisas mt básicas e vc demora horas pra vir aqui responder, ja tá durando 5 dias esse teu problema..
 

Spoiler

--PERFECT UPGRADE SYSTEM

    UpgradeHandler = {
		nameLv = {
		    [1] = "UNIQ",
		    [2] = "RARE",
		    [3] = "EPIC"
	    },
        levels = {
              [1] = {50, false, false},
              [2] = {20, false, false},
              [3] = {10, true, true}
        },
        broadcast = 3,
        attributes = {
              ["attack"] = 3,
              ["defense"] = 2,
              ["armor"] = 1
        },
        message = {
              console = "Trying to refine %s to level +%s with %s%% success rate.",
              success = "You have upgraded %s to level +%s",
              fail = "You have failed in upgrade of %s to level +%s",
              downgrade = "The upgrade level of %s has downgraded to +%s",
              erase = "The upgrade level of %s has been erased.",
              maxlevel = "The targeted %s is already on max upgrade level.",
              notupgradeable = "This item is not upgradeable.",
              broadcast = "The player %s was successful in upgrading %s to level +%s.\nCongratulations!!",
              invalidtool = "This is not a valid upgrade tool.",
              toolrange = "This upgrade tool can only be used in items with level between +%s and +%s"
        },
        tools = {
            [8306] = {range = {0, 10}, info = {chance = 0, removeable = true}},
            [8300] = {range = {0, 10}, info = {chance = 0, removeable = true}}
        },
        isEquipment = function(self)
            local weaponType = self:getItemWeaponType()
            return ((weaponType > 0 and weaponType < 7) or self.item.armor ~= 0)
        end,
        setItemName = function(self, name)
            return doItemSetAttribute(self.item.uid, "name", name)
        end,
        chance = function(self)
            local chances = {}
            chances.upgrade = (self.levels[self.item.level + 1][1] or 100)
            chances.downgrade = (self.item.level * 5)
            chances.erase = (self.item.level * 3)
            return chances
        end
    }

    function UpgradeHandler:new(item)
        local obj, ret = {}
        obj.item = {}
        obj.item.level = 0
        obj.item.uid = item.uid
        for key, value in pairs(getItemInfo(item.itemid)) do
            obj.item[key] = value
        end
        ret = setmetatable(obj, {
            __index = function(self, index)
                if _G[index] then
                    return (setmetatable({callback = _G[index]},
                        {__call = function(self, ...)
                            return self.callback(item.uid, ...)
                        end}
                    ))
                else
                    return UpgradeHandler[index]
                end
        end})

        if ret:isEquipment() then
            ret:update()
            return ret
        end
        return false
    end


    function UpgradeHandler:update()
       -- this will return the level by the quality or 0 if it has no quality.
        self.item.level = 0
		for r, v in ipairs(self.nameLv) do
		    if self:getItemName():find(v) then
		        self.item.level = r
		    end
		end
    end

    function UpgradeHandler:refine(uid, item)
        if not self.item then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.notupgradeable)
            return "miss"
        end

        local tool = self.tools[item.itemid]
        if(tool == nil) then
            doPlayerSendTextMessage(uid, MESSAGE_EVENT_DEFAULT, self.message.invalidtool)
            return "miss"
        end

        if(self.item.level > #self.levels) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.maxlevel:format(self.item.name))
            return "miss"
        end

        if(self.item.level < tool.range[1] or self.item.level >= tool.range[2]) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.toolrange:format(unpack(tool.range)))
            return "miss"
        end

        local chance = (self:chance().upgrade + tool.info.chance)
        doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.console:format(self.item.name, (self.item.level + 1), math.min(100, chance)))
        if(tool.info.removeable == true) then
            doRemoveItem(item.uid, 1)
        end

        if chance * 100 > math.random(1, 10000) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1)))
            if (self.item.level + 1) >= self.broadcast then
                doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1)))
            end
            -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
            -- if the current level equals 0 add 1 to it
            self:setItemName(self.item.level > 0 and (self.nameLv[self.item.level].." "..self:getItemName()):gsub((self.nameLv[self.item.level].." "), "") or self.nameLv[1].." "..self:getItemName())
            for key, value in pairs(self.attributes) do
                if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                    doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value)
                end
            end
            return "success"
        else
            if item.itemid == 8300 then
                if self.item.level > 0 then
                    -- this will remove any number with a + sign in front of it from the string
                    self:setItemName(self:getItemName():gsub((self.nameLv[self.item.level].." "), ""))
                    for key, value in pairs(self.attributes) do
                        if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                            doItemSetAttribute(self.item.uid, key, getItemAttribute(self.item.uid, key) - self.item.level * value)
                        end
                    end
                end
            else
                doRemoveItem(self.item.uid, 1)
            end
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, item.itemid == 8300 and "Your item level has been reseted." or "You have broken your item while trying to upgrade it.")
        end
    end

 

 

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

Link para o post
Compartilhar em outros sites
4 horas atrás, xWhiteWolf disse:

kct, to decepcionado cmg msmo AHUEUHA to esquecendo umas coisas mt básicas e vc demora horas pra vir aqui responder, ja tá durando 5 dias esse teu problema..
 

  Ocultar conteúdo



--PERFECT UPGRADE SYSTEM

    UpgradeHandler = {
		nameLv = {
		    [1] = "UNIQ",
		    [2] = "RARE",
		    [3] = "EPIC"
	    },
        levels = {
              [1] = {50, false, false},
              [2] = {20, false, false},
              [3] = {10, true, true}
        },
        broadcast = 3,
        attributes = {
              ["attack"] = 3,
              ["defense"] = 2,
              ["armor"] = 1
        },
        message = {
              console = "Trying to refine %s to level +%s with %s%% success rate.",
              success = "You have upgraded %s to level +%s",
              fail = "You have failed in upgrade of %s to level +%s",
              downgrade = "The upgrade level of %s has downgraded to +%s",
              erase = "The upgrade level of %s has been erased.",
              maxlevel = "The targeted %s is already on max upgrade level.",
              notupgradeable = "This item is not upgradeable.",
              broadcast = "The player %s was successful in upgrading %s to level +%s.\nCongratulations!!",
              invalidtool = "This is not a valid upgrade tool.",
              toolrange = "This upgrade tool can only be used in items with level between +%s and +%s"
        },
        tools = {
            [8306] = {range = {0, 10}, info = {chance = 0, removeable = true}},
            [8300] = {range = {0, 10}, info = {chance = 0, removeable = true}}
        },
        isEquipment = function(self)
            local weaponType = self:getItemWeaponType()
            return ((weaponType > 0 and weaponType < 7) or self.item.armor ~= 0)
        end,
        setItemName = function(self, name)
            return doItemSetAttribute(self.item.uid, "name", name)
        end,
        chance = function(self)
            local chances = {}
            chances.upgrade = (self.levels[self.item.level + 1][1] or 100)
            chances.downgrade = (self.item.level * 5)
            chances.erase = (self.item.level * 3)
            return chances
        end
    }

    function UpgradeHandler:new(item)
        local obj, ret = {}
        obj.item = {}
        obj.item.level = 0
        obj.item.uid = item.uid
        for key, value in pairs(getItemInfo(item.itemid)) do
            obj.item[key] = value
        end
        ret = setmetatable(obj, {
            __index = function(self, index)
                if _G[index] then
                    return (setmetatable({callback = _G[index]},
                        {__call = function(self, ...)
                            return self.callback(item.uid, ...)
                        end}
                    ))
                else
                    return UpgradeHandler[index]
                end
        end})

        if ret:isEquipment() then
            ret:update()
            return ret
        end
        return false
    end


    function UpgradeHandler:update()
       -- this will return the level by the quality or 0 if it has no quality.
        self.item.level = 0
		for r, v in ipairs(self.nameLv) do
		    if self:getItemName():find(v) then
		        self.item.level = r
		    end
		end
    end

    function UpgradeHandler:refine(uid, item)
        if not self.item then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.notupgradeable)
            return "miss"
        end

        local tool = self.tools[item.itemid]
        if(tool == nil) then
            doPlayerSendTextMessage(uid, MESSAGE_EVENT_DEFAULT, self.message.invalidtool)
            return "miss"
        end

        if(self.item.level > #self.levels) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.maxlevel:format(self.item.name))
            return "miss"
        end

        if(self.item.level < tool.range[1] or self.item.level >= tool.range[2]) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.toolrange:format(unpack(tool.range)))
            return "miss"
        end

        local chance = (self:chance().upgrade + tool.info.chance)
        doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.console:format(self.item.name, (self.item.level + 1), math.min(100, chance)))
        if(tool.info.removeable == true) then
            doRemoveItem(item.uid, 1)
        end

        if chance * 100 > math.random(1, 10000) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1)))
            if (self.item.level + 1) >= self.broadcast then
                doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1)))
            end
            -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
            -- if the current level equals 0 add 1 to it
            self:setItemName(self.item.level > 0 and (self.nameLv[self.item.level].." "..self:getItemName()):gsub((self.nameLv[self.item.level].." "), "") or self.nameLv[1].." "..self:getItemName())
            for key, value in pairs(self.attributes) do
                if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                    doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value)
                end
            end
            return "success"
        else
            if item.itemid == 8300 then
                if self.item.level > 0 then
                    -- this will remove any number with a + sign in front of it from the string
                    self:setItemName(self:getItemName():gsub((self.nameLv[self.item.level].." "), ""))
                    for key, value in pairs(self.attributes) do
                        if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                            doItemSetAttribute(self.item.uid, key, getItemAttribute(self.item.uid, key) - self.item.level * value)
                        end
                    end
                end
            else
                doRemoveItem(self.item.uid, 1)
            end
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, item.itemid == 8300 and "Your item level has been reseted." or "You have broken your item while trying to upgrade it.")
        end
    end

 

 

 

 

Cara muito obrigado mesmo!!!!!!!!!!!

Uma coisa, se não for folgar muito, testando seu script vi que ta aumentando a defesa de armas de atk

 

Tipo uma sword que era pra aumentar só o atk dela, ta aumentando +2 de defense que era pra ser aumentado só de shields

 

Essa parte ta na lib? Unica coisa q vi de atributes na lib é isso, q n entendi porra nenhuma

 

 

        if chance * 100 > math.random(1, 10000) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1)))
            if (self.item.level + 1) >= self.broadcast then
                doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1)))
            end
            -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
            -- if the current level equals 0 add 1 to it
            self:setItemName(self.item.level > 0 and (self.nameLv[self.item.level].." "..self:getItemName()):gsub((self.nameLv[self.item.level].." "), "") or self.nameLv[1].." "..self:getItemName())
            for key, value in pairs(self.attributes) do
                if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                    doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value)
                end
            end
            return "success"
        else
            if item.itemid == 8300 then
                if self.item.level > 0 then
                    -- this will remove any number with a + sign in front of it from the string
                    self:setItemName(self:getItemName():gsub((self.nameLv[self.item.level].." "), ""))
                    for key, value in pairs(self.attributes) do
                        if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                            doItemSetAttribute(self.item.uid, key, getItemAttribute(self.item.uid, key) - self.item.level * value)
                        end
                    end
                end
            else
                doRemoveItem(self.item.uid, 1)
            end
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, item.itemid == 8300 and "Your item level has been reseted." or "You have broken your item while trying to upgrade it.")
        end

 

 

 

 

Sabe arrumar isso?

Editado por gmstrikker (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

o script não é meu, só fiz uma modificação pra ficar do jeito q vc queria. Não mexi em nada dessa parte de atributos então deve tar como era pra ser. Se ele tá aumentando algo errado verifica se é a configuração que tá errada, do contrário eu dou uma revisada e vejo se acho algum erro de lógica

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

Link para o post
Compartilhar em outros sites
17 horas atrás, xWhiteWolf disse:

o script não é meu, só fiz uma modificação pra ficar do jeito q vc queria. Não mexi em nada dessa parte de atributos então deve tar como era pra ser. Se ele tá aumentando algo errado verifica se é a configuração que tá errada, do contrário eu dou uma revisada e vejo se acho algum erro de lógica

 

É isso era do antigo script memso, mas ainda tem bug nessa sua modficação...

Quando eu tento botar uma arma +2, não funciona e provavelmente +3 tbm n, só a +1


+1 = 01:18 You see a UNIQ carlin sword (Atk:18, Def:15).
+2? = 01:18 You see a carlin sword (Atk:21, Def:17).


Dps tento +3 volta pra +1

 

Link para o post
Compartilhar em outros sites

Testa assim, acredito que possa dar erro ao tentar dar upgrade em um item Épico caso as outras checagens do script falhem, mas a lógica tá impecável:
 

Spoiler

--PERFECT UPGRADE SYSTEM

    UpgradeHandler = {
		nameLv = {
		    [1] = "UNIQ",
		    [2] = "RARE",
		    [3] = "EPIC"
	    },
        levels = {
              [1] = {50, false, false},
              [2] = {20, false, false},
              [3] = {10, true, true}
        },
        broadcast = 3,
        attributes = {
              ["attack"] = 3,
              ["defense"] = 2,
              ["armor"] = 1
        },
        message = {
              console = "Trying to refine %s to level +%s with %s%% success rate.",
              success = "You have upgraded %s to level +%s",
              fail = "You have failed in upgrade of %s to level +%s",
              downgrade = "The upgrade level of %s has downgraded to +%s",
              erase = "The upgrade level of %s has been erased.",
              maxlevel = "The targeted %s is already on max upgrade level.",
              notupgradeable = "This item is not upgradeable.",
              broadcast = "The player %s was successful in upgrading %s to level +%s.\nCongratulations!!",
              invalidtool = "This is not a valid upgrade tool.",
              toolrange = "This upgrade tool can only be used in items with level between +%s and +%s"
        },
        tools = {
            [8306] = {range = {0, 10}, info = {chance = 0, removeable = true}},
            [8300] = {range = {0, 10}, info = {chance = 0, removeable = true}}
        },
        isEquipment = function(self)
            local weaponType = self:getItemWeaponType()
            return ((weaponType > 0 and weaponType < 7) or self.item.armor ~= 0)
        end,
        setItemName = function(self, name)
            return doItemSetAttribute(self.item.uid, "name", name)
        end,
        chance = function(self)
            local chances = {}
            chances.upgrade = (self.levels[self.item.level + 1][1] or 100)
            chances.downgrade = (self.item.level * 5)
            chances.erase = (self.item.level * 3)
            return chances
        end
    }

    function UpgradeHandler:new(item)
        local obj, ret = {}
        obj.item = {}
        obj.item.level = 0
        obj.item.uid = item.uid
        for key, value in pairs(getItemInfo(item.itemid)) do
            obj.item[key] = value
        end
        ret = setmetatable(obj, {
            __index = function(self, index)
                if _G[index] then
                    return (setmetatable({callback = _G[index]},
                        {__call = function(self, ...)
                            return self.callback(item.uid, ...)
                        end}
                    ))
                else
                    return UpgradeHandler[index]
                end
        end})

        if ret:isEquipment() then
            ret:update()
            return ret
        end
        return false
    end


    function UpgradeHandler:update()
       -- this will return the level by the quality or 0 if it has no quality.
        self.item.level = 0
		for r, v in ipairs(self.nameLv) do
		    if self:getItemName():find(v) then
		        self.item.level = r
		    end
		end
    end

    function UpgradeHandler:refine(uid, item)
        if not self.item then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.notupgradeable)
            return "miss"
        end

        local tool = self.tools[item.itemid]
        if(tool == nil) then
            doPlayerSendTextMessage(uid, MESSAGE_EVENT_DEFAULT, self.message.invalidtool)
            return "miss"
        end

        if(self.item.level > #self.levels) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.maxlevel:format(self.item.name))
            return "miss"
        end

        if(self.item.level < tool.range[1] or self.item.level >= tool.range[2]) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.toolrange:format(unpack(tool.range)))
            return "miss"
        end

        local chance = (self:chance().upgrade + tool.info.chance)
        doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.console:format(self.item.name, (self.item.level + 1), math.min(100, chance)))
        if(tool.info.removeable == true) then
            doRemoveItem(item.uid, 1)
        end

        if chance * 100 > math.random(1, 10000) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1)))
            if (self.item.level + 1) >= self.broadcast then
                doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1)))
            end
            -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
            -- if the current level equals 0 add 1 to it
            self:setItemName(self.item.level > 0 and self.nameLv[self.item.level + 1].." "..(self:getItemName():gsub(self.nameLv[self.item.level].." ", "")) or self.nameLv[1].." "..self:getItemName())
            for key, value in pairs(self.attributes) do
                if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                    doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value)
                end
            end
            return "success"
        else
            if item.itemid == 8300 then
                if self.item.level > 0 then
                    -- this will remove any number with a + sign in front of it from the string
                    self:setItemName(self:getItemName():gsub((self.nameLv[self.item.level].." "), ""))
                    for key, value in pairs(self.attributes) do
                        if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                            doItemSetAttribute(self.item.uid, key, getItemAttribute(self.item.uid, key) - self.item.level * value)
                        end
                    end
                end
            else
                doRemoveItem(self.item.uid, 1)
            end
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, item.itemid == 8300 and "Your item level has been reseted." or "You have broken your item while trying to upgrade it.")
        end
    end

 




Edit: entra nesse site aqui https://repl.it/languages/Lua/
e coloca esse código na caixa à esquerda e clica em Run ►

 

local itemname = "UNIQ KATANA"

nameLv = {
		    [1] = "UNIQ",
		    [2] = "RARE",
		    [3] = "EPIC"
	    }

lvl = 0
		for r, v in ipairs(nameLv) do
		    if itemname:find(v) then
		        lvl = r
		    end
	end
	
print("O level atual do item é: "..lvl)

if lvl >= #nameLv then print("O item não pode ser mais customizado.") else
local a = lvl > 0 and nameLv[lvl + 1].." "..itemname:gsub((nameLv[lvl].." "), "") or nameLv[1].." "..itemname
print("Após a customização o item ficará como: ".. a)
end

Apenas mudando o nome do item ali em cima vc consegue simular oque aconteceria no script;

Editado por xWhiteWolf (veja o histórico de edições)

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

Link para o post
Compartilhar em outros sites
Em 05/02/2016 11:12:56, xWhiteWolf disse:

Testa assim, acredito que possa dar erro ao tentar dar upgrade em um item Épico caso as outras checagens do script falhem, mas a lógica tá impecável:
 

  Mostrar conteúdo oculto


--PERFECT UPGRADE SYSTEM

    UpgradeHandler = {
		nameLv = {
		    [1] = "UNIQ",
		    [2] = "RARE",
		    [3] = "EPIC"
	    },
        levels = {
              [1] = {50, false, false},
              [2] = {20, false, false},
              [3] = {10, true, true}
        },
        broadcast = 3,
        attributes = {
              ["attack"] = 3,
              ["defense"] = 2,
              ["armor"] = 1
        },
        message = {
              console = "Trying to refine %s to level +%s with %s%% success rate.",
              success = "You have upgraded %s to level +%s",
              fail = "You have failed in upgrade of %s to level +%s",
              downgrade = "The upgrade level of %s has downgraded to +%s",
              erase = "The upgrade level of %s has been erased.",
              maxlevel = "The targeted %s is already on max upgrade level.",
              notupgradeable = "This item is not upgradeable.",
              broadcast = "The player %s was successful in upgrading %s to level +%s.\nCongratulations!!",
              invalidtool = "This is not a valid upgrade tool.",
              toolrange = "This upgrade tool can only be used in items with level between +%s and +%s"
        },
        tools = {
            [8306] = {range = {0, 10}, info = {chance = 0, removeable = true}},
            [8300] = {range = {0, 10}, info = {chance = 0, removeable = true}}
        },
        isEquipment = function(self)
            local weaponType = self:getItemWeaponType()
            return ((weaponType > 0 and weaponType < 7) or self.item.armor ~= 0)
        end,
        setItemName = function(self, name)
            return doItemSetAttribute(self.item.uid, "name", name)
        end,
        chance = function(self)
            local chances = {}
            chances.upgrade = (self.levels[self.item.level + 1][1] or 100)
            chances.downgrade = (self.item.level * 5)
            chances.erase = (self.item.level * 3)
            return chances
        end
    }

    function UpgradeHandler:new(item)
        local obj, ret = {}
        obj.item = {}
        obj.item.level = 0
        obj.item.uid = item.uid
        for key, value in pairs(getItemInfo(item.itemid)) do
            obj.item[key] = value
        end
        ret = setmetatable(obj, {
            __index = function(self, index)
                if _G[index] then
                    return (setmetatable({callback = _G[index]},
                        {__call = function(self, ...)
                            return self.callback(item.uid, ...)
                        end}
                    ))
                else
                    return UpgradeHandler[index]
                end
        end})

        if ret:isEquipment() then
            ret:update()
            return ret
        end
        return false
    end


    function UpgradeHandler:update()
       -- this will return the level by the quality or 0 if it has no quality.
        self.item.level = 0
		for r, v in ipairs(self.nameLv) do
		    if self:getItemName():find(v) then
		        self.item.level = r
		    end
		end
    end

    function UpgradeHandler:refine(uid, item)
        if not self.item then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.notupgradeable)
            return "miss"
        end

        local tool = self.tools[item.itemid]
        if(tool == nil) then
            doPlayerSendTextMessage(uid, MESSAGE_EVENT_DEFAULT, self.message.invalidtool)
            return "miss"
        end

        if(self.item.level > #self.levels) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.maxlevel:format(self.item.name))
            return "miss"
        end

        if(self.item.level < tool.range[1] or self.item.level >= tool.range[2]) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.toolrange:format(unpack(tool.range)))
            return "miss"
        end

        local chance = (self:chance().upgrade + tool.info.chance)
        doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.console:format(self.item.name, (self.item.level + 1), math.min(100, chance)))
        if(tool.info.removeable == true) then
            doRemoveItem(item.uid, 1)
        end

        if chance * 100 > math.random(1, 10000) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1)))
            if (self.item.level + 1) >= self.broadcast then
                doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1)))
            end
            -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
            -- if the current level equals 0 add 1 to it
            self:setItemName(self.item.level > 0 and self.nameLv[self.item.level + 1].." "..(self:getItemName():gsub(self.nameLv[self.item.level].." ", "")) or self.nameLv[1].." "..self:getItemName())
            for key, value in pairs(self.attributes) do
                if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                    doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value)
                end
            end
            return "success"
        else
            if item.itemid == 8300 then
                if self.item.level > 0 then
                    -- this will remove any number with a + sign in front of it from the string
                    self:setItemName(self:getItemName():gsub((self.nameLv[self.item.level].." "), ""))
                    for key, value in pairs(self.attributes) do
                        if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                            doItemSetAttribute(self.item.uid, key, getItemAttribute(self.item.uid, key) - self.item.level * value)
                        end
                    end
                end
            else
                doRemoveItem(self.item.uid, 1)
            end
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, item.itemid == 8300 and "Your item level has been reseted." or "You have broken your item while trying to upgrade it.")
        end
    end

 




Edit: entra nesse site aqui https://repl.it/languages/Lua/
e coloca esse código na caixa à esquerda e clica em Run ►

 


local itemname = "UNIQ KATANA"

nameLv = {
		    [1] = "UNIQ",
		    [2] = "RARE",
		    [3] = "EPIC"
	    }

lvl = 0
		for r, v in ipairs(nameLv) do
		    if itemname:find(v) then
		        lvl = r
		    end
	end
	
print("O level atual do item é: "..lvl)

if lvl >= #nameLv then print("O item não pode ser mais customizado.") else
local a = lvl > 0 and nameLv[lvl + 1].." "..itemname:gsub((nameLv[lvl].." "), "") or nameLv[1].." "..itemname
print("Após a customização o item ficará como: ".. a)
end

Apenas mudando o nome do item ali em cima vc consegue simular oque aconteceria no script;

 

 

 

 

EDIT

desculpa não tinha lido direito

Editado por gmstrikker (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • 4 months later...
Em 05/02/2016 at 11:12, xWhiteWolf disse:

Testa assim, acredito que possa dar erro ao tentar dar upgrade em um item Épico caso as outras checagens do script falhem, mas a lógica tá impecável:
 

  Mostrar conteúdo oculto


--PERFECT UPGRADE SYSTEM

    UpgradeHandler = {
		nameLv = {
		    [1] = "UNIQ",
		    [2] = "RARE",
		    [3] = "EPIC"
	    },
        levels = {
              [1] = {50, false, false},
              [2] = {20, false, false},
              [3] = {10, true, true}
        },
        broadcast = 3,
        attributes = {
              ["attack"] = 3,
              ["defense"] = 2,
              ["armor"] = 1
        },
        message = {
              console = "Trying to refine %s to level +%s with %s%% success rate.",
              success = "You have upgraded %s to level +%s",
              fail = "You have failed in upgrade of %s to level +%s",
              downgrade = "The upgrade level of %s has downgraded to +%s",
              erase = "The upgrade level of %s has been erased.",
              maxlevel = "The targeted %s is already on max upgrade level.",
              notupgradeable = "This item is not upgradeable.",
              broadcast = "The player %s was successful in upgrading %s to level +%s.\nCongratulations!!",
              invalidtool = "This is not a valid upgrade tool.",
              toolrange = "This upgrade tool can only be used in items with level between +%s and +%s"
        },
        tools = {
            [8306] = {range = {0, 10}, info = {chance = 0, removeable = true}},
            [8300] = {range = {0, 10}, info = {chance = 0, removeable = true}}
        },
        isEquipment = function(self)
            local weaponType = self:getItemWeaponType()
            return ((weaponType > 0 and weaponType < 7) or self.item.armor ~= 0)
        end,
        setItemName = function(self, name)
            return doItemSetAttribute(self.item.uid, "name", name)
        end,
        chance = function(self)
            local chances = {}
            chances.upgrade = (self.levels[self.item.level + 1][1] or 100)
            chances.downgrade = (self.item.level * 5)
            chances.erase = (self.item.level * 3)
            return chances
        end
    }

    function UpgradeHandler:new(item)
        local obj, ret = {}
        obj.item = {}
        obj.item.level = 0
        obj.item.uid = item.uid
        for key, value in pairs(getItemInfo(item.itemid)) do
            obj.item[key] = value
        end
        ret = setmetatable(obj, {
            __index = function(self, index)
                if _G[index] then
                    return (setmetatable({callback = _G[index]},
                        {__call = function(self, ...)
                            return self.callback(item.uid, ...)
                        end}
                    ))
                else
                    return UpgradeHandler[index]
                end
        end})

        if ret:isEquipment() then
            ret:update()
            return ret
        end
        return false
    end


    function UpgradeHandler:update()
       -- this will return the level by the quality or 0 if it has no quality.
        self.item.level = 0
		for r, v in ipairs(self.nameLv) do
		    if self:getItemName():find(v) then
		        self.item.level = r
		    end
		end
    end

    function UpgradeHandler:refine(uid, item)
        if not self.item then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.notupgradeable)
            return "miss"
        end

        local tool = self.tools[item.itemid]
        if(tool == nil) then
            doPlayerSendTextMessage(uid, MESSAGE_EVENT_DEFAULT, self.message.invalidtool)
            return "miss"
        end

        if(self.item.level > #self.levels) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.maxlevel:format(self.item.name))
            return "miss"
        end

        if(self.item.level < tool.range[1] or self.item.level >= tool.range[2]) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.toolrange:format(unpack(tool.range)))
            return "miss"
        end

        local chance = (self:chance().upgrade + tool.info.chance)
        doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.console:format(self.item.name, (self.item.level + 1), math.min(100, chance)))
        if(tool.info.removeable == true) then
            doRemoveItem(item.uid, 1)
        end

        if chance * 100 > math.random(1, 10000) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1)))
            if (self.item.level + 1) >= self.broadcast then
                doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1)))
            end
            -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
            -- if the current level equals 0 add 1 to it
            self:setItemName(self.item.level > 0 and self.nameLv[self.item.level + 1].." "..(self:getItemName():gsub(self.nameLv[self.item.level].." ", "")) or self.nameLv[1].." "..self:getItemName())
            for key, value in pairs(self.attributes) do
                if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                    doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value)
                end
            end
            return "success"
        else
            if item.itemid == 8300 then
                if self.item.level > 0 then
                    -- this will remove any number with a + sign in front of it from the string
                    self:setItemName(self:getItemName():gsub((self.nameLv[self.item.level].." "), ""))
                    for key, value in pairs(self.attributes) do
                        if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                            doItemSetAttribute(self.item.uid, key, getItemAttribute(self.item.uid, key) - self.item.level * value)
                        end
                    end
                end
            else
                doRemoveItem(self.item.uid, 1)
            end
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, item.itemid == 8300 and "Your item level has been reseted." or "You have broken your item while trying to upgrade it.")
        end
    end

 




Edit: entra nesse site aqui https://repl.it/languages/Lua/
e coloca esse código na caixa à esquerda e clica em Run ►

 


local itemname = "UNIQ KATANA"

nameLv = {
		    [1] = "UNIQ",
		    [2] = "RARE",
		    [3] = "EPIC"
	    }

lvl = 0
		for r, v in ipairs(nameLv) do
		    if itemname:find(v) then
		        lvl = r
		    end
	end
	
print("O level atual do item é: "..lvl)

if lvl >= #nameLv then print("O item não pode ser mais customizado.") else
local a = lvl > 0 and nameLv[lvl + 1].." "..itemname:gsub((nameLv[lvl].." "), "") or nameLv[1].." "..itemname
print("Após a customização o item ficará como: ".. a)
end

Apenas mudando o nome do item ali em cima vc consegue simular oque aconteceria no script;

 

 

White, depois de todo esse tempo testando o ot sozinho, ontem testando com uns amigos todo mundo refinando uma hora deu um erro e depois ninguem mais conseguiu refinar...

 

Pelo que eu entendi o problema é no return "sucess", mas ta certinho não ta?


Sabe me dizer o que pode ser?

 

Error

[23:57:13.709] [Error - Action Interface]
[23:57:13.709] data/actions/scripts/upgrade.lua:onUse
[23:57:13.709] Description:
[23:57:13.709] data/lib/upgradesystem.lua:108: attempt to index a boolean value
[23:57:13.709] stack traceback:
[23:57:13.710]    data/lib/upgradesystem.lua:108: in function 'refine'
[23:57:13.710]    data/actions/scripts/upgrade.lua:12: in function <data/actions/scripts/upgrade.lua:1>

[23:57:19.666] [Error - Action Interface]
[23:57:19.666] data/actions/scripts/upgrade.lua:onUse
[23:57:19.666] Description:
[23:57:19.667] data/lib/upgradesystem.lua:108: attempt to index a boolean value
[23:57:19.667] stack traceback:
[23:57:19.667]    data/lib/upgradesystem.lua:108: in function 'refine'
[23:57:19.667]    data/actions/scripts/upgrade.lua:12: in function <data/actions/scripts/upgrade.lua:1>

[23:57:28.575] [Error - Action Interface]
[23:57:28.575] data/actions/scripts/upgrade.lua:onUse
[23:57:28.575] Description:
[23:57:28.575] data/lib/upgradesystem.lua:108: attempt to index a boolean value
[23:57:28.575] stack traceback:
[23:57:28.575]    data/lib/upgradesystem.lua:108: in function 'refine'
[23:57:28.575]    data/actions/scripts/upgrade.lua:12: in function <data/actions/scripts/upgrade.lua:1>

[23:57:43.396] [Error - Action Interface]
[23:57:43.397] data/actions/scripts/upgrade.lua:onUse
[23:57:43.397] Description:
[23:57:43.397] data/lib/upgradesystem.lua:108: attempt to index a boolean value
[23:57:43.397] stack traceback:
[23:57:43.397]    data/lib/upgradesystem.lua:108: in function 'refine'
[23:57:43.397]    data/actions/scripts/upgrade.lua:12: in function <data/actions/scripts/upgrade.lua:1>

[23:57:45.493] [Error - Action Interface]
[23:57:45.493] data/actions/scripts/upgrade.lua:onUse
[23:57:45.493] Description:
[23:57:45.493] data/lib/upgradesystem.lua:108: attempt to index a boolean value
[23:57:45.493] stack traceback:
[23:57:45.493]    data/lib/upgradesystem.lua:108: in function 'refine'
[23:57:45.493]    data/actions/scripts/upgrade.lua:12: in function <data/actions/scripts/upgrade.lua:1>

 

 

data/lib/upgradesystem.lua

  --PERFECT UPGRADE SYSTEM
  UpgradeHandler = {
  nameLv = {
  [1] = "UNIQ",
  [2] = "RARE",
  [3] = "EPIC"
  },
  levels = {
  [1] = {50, false, false},
  [2] = {30, false, false},
  [3] = {15, true, true}
  },
  broadcast = 4, -- não quero broad
  attributes = {
  ["attack"] = 3,
  ["defense"] = 2,
  ["armor"] = 1
  },
  message = {
  console = "Trying to refine %s to level +%s with %s%% success rate.",
  success = "You have upgraded %s to level +%s",
  fail = "You have failed in upgrade of %s to level +%s",
  downgrade = "The upgrade level of %s has downgraded to +%s",
  erase = "The upgrade level of %s has been erased.",
  maxlevel = "The targeted %s is already on max upgrade level.",
  notupgradeable = "This item is not upgradeable.",
  broadcast = "The player %s was successful in upgrading %s to level +%s.\nCongratulations!!",
  invalidtool = "This is not a valid upgrade tool.",
  toolrange = "This upgrade tool can only be used in items with level between +%s and +%s"
  },
  tools = {
  [8306] = {range = {0, 10}, info = {chance = 1, removeable = true}},
  [8300] = {range = {0, 10}, info = {chance = 2, removeable = true}}
  },
  isEquipment = function(self)
  local weaponType = self:getItemWeaponType()
  return ((weaponType > 0 and weaponType < 8) or self.item.armor ~= 0)
  end,
  setItemName = function(self, name)
  return doItemSetAttribute(self.item.uid, "name", name)
  end,
  chance = function(self)
  local chances = {}
  chances.upgrade = (self.levels[self.item.level + 1][1] or 100)
  chances.downgrade = (self.item.level * 5)
  chances.erase = (self.item.level * 3)
  return chances
  end
  }
  function UpgradeHandler:new(item)
  local obj, ret = {}
  obj.item = {}
  obj.item.level = 0
  obj.item.uid = item.uid
  for key, value in pairs(getItemInfo(item.itemid)) do
  obj.item[key] = value
  end
  ret = setmetatable(obj, {
  __index = function(self, index)
  if _G[index] then
  return (setmetatable({callback = _G[index]},
  {__call = function(self, ...)
  return self.callback(item.uid, ...)
  end}
  ))
  else
  return UpgradeHandler[index]
  end
  end})
  if ret:isEquipment() then
  ret:update()
  return ret
  end
  return false
  end
  function UpgradeHandler:update()
  -- this will return the level by the quality or 0 if it has no quality.
  self.item.level = 0
  for r, v in ipairs(self.nameLv) do
  if self:getItemName():find(v) then
  self.item.level = r
  end
  end
  end
  function UpgradeHandler:refine(uid, item)
  if (self.item.level >= 3) then
  return true
  end
   
  if not self.item then
  doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.notupgradeable)
  return "miss"
  end
  local tool = self.tools[item.itemid]
  if(tool == nil) then
  doPlayerSendTextMessage(uid, MESSAGE_EVENT_DEFAULT, self.message.invalidtool)
  return "miss"
  end
  if(self.item.level > #self.levels) then
  doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.maxlevel:format(self.item.name))
  return "miss"
  end
  if(self.item.level < tool.range[1] or self.item.level >= tool.range[2]) then
  doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.toolrange:format(unpack(tool.range)))
  return "miss"
  end
  local chance = (self:chance().upgrade * tool.info.chance)
  doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.console:format(self.item.name, (self.item.level + 1), math.min(100, chance)))
  if(tool.info.removeable == true) then
  doRemoveItem(item.uid, 1)
  end
  if chance * 100 > math.random(1, 10000) then
  doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1)))
  if (self.item.level + 1) >= self.broadcast then
  doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1)))
  end
  -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
  -- if the current level equals 0 add 1 to it
  self:setItemName(self.item.level > 0 and self.nameLv[self.item.level + 1].." "..(self:getItemName():gsub(self.nameLv[self.item.level].." ", "")) or self.nameLv[1].." "..self:getItemName())
  for key, value in pairs(self.attributes) do
  if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
  doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value)
  end
  end
  return "success"
  else
  if item.itemid == 8300 then
  if self.item.level > 0 then
  -- this will remove any number with a + sign in front of it from the string
  self:setItemName(self:getItemName():gsub((self.nameLv[self.item.level].." "), ""))
  for key, value in pairs(self.attributes) do
  if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
  doItemSetAttribute(self.item.uid, key, getItemAttribute(self.item.uid, key) - self.item.level * value)
  end
  end
  end
  else
  doRemoveItem(self.item.uid, 1)
  end
  doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, item.itemid == 8300 and "Your item level has been reseted." or "You have broken your item while trying to upgrade it.")
  end
  end

 

data/actions/scripts/upgrade.lua

 

function onUse(cid, item, fromPosition, itemEx, toPosition)
  if isCreature(itemEx.uid) then   
  return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
  end

  local obj = UpgradeHandler:new(itemEx)

  if(obj == false) then
  return doPlayerSendCancel(cid, UpgradeHandler.message.notupgradeable)
  end

  local status = obj:refine(cid, item)
  if status == "success" then
  --doSendAnimatedText(toPosition, "Success!", COLOR_GREEN)
  doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
  elseif status == "fail" then
  --doSendAnimatedText(toPosition, "Fail!", COLOR_RED)
  doSendMagicEffect(toPosition, CONST_ME_POFF)
  else
  doSendMagicEffect(toPosition, CONST_ME_POFF)
  end
  return true
end

 

 

Editado por gmstrikker (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

q erro bizarro.. enfim, tenta assim: 

Spoiler

--PERFECT UPGRADE SYSTEM

    UpgradeHandler = {
		nameLv = {
		    [1] = "UNIQ",
		    [2] = "RARE",
		    [3] = "EPIC"
	    },
        levels = {
              [1] = {50, false, false},
              [2] = {20, false, false},
              [3] = {10, true, true}
        },
        broadcast = 3,
        attributes = {
              ["attack"] = 3,
              ["defense"] = 2,
              ["armor"] = 1
        },
        message = {
              console = "Trying to refine %s to level +%s with %s%% success rate.",
              success = "You have upgraded %s to level +%s",
              fail = "You have failed in upgrade of %s to level +%s",
              downgrade = "The upgrade level of %s has downgraded to +%s",
              erase = "The upgrade level of %s has been erased.",
              maxlevel = "The targeted %s is already on max upgrade level.",
              notupgradeable = "This item is not upgradeable.",
              broadcast = "The player %s was successful in upgrading %s to level +%s.\nCongratulations!!",
              invalidtool = "This is not a valid upgrade tool.",
              toolrange = "This upgrade tool can only be used in items with level between +%s and +%s"
        },
        tools = {
            [8306] = {range = {0, 10}, info = {chance = 0, removeable = true}},
            [8300] = {range = {0, 10}, info = {chance = 0, removeable = true}}
        },
        isEquipment = function(self)
            local weaponType = self:getItemWeaponType()
            return ((weaponType > 0 and weaponType < 7) or self.item.armor ~= 0)
        end,
        setItemName = function(self, name)
            return doItemSetAttribute(self.item.uid, "name", name)
        end,
        chance = function(self)
            local chances = {}
            chances.upgrade = (self.levels[self.item.level + 1][1] or 100)
            chances.downgrade = (self.item.level * 5)
            chances.erase = (self.item.level * 3)
            return chances
        end
    }

    function UpgradeHandler:new(item)
        local obj, ret = {}
        obj.item = {}
        obj.item.level = 0
        obj.item.uid = item.uid
        for key, value in pairs(getItemInfo(item.itemid)) do
            obj.item[key] = value
        end
        ret = setmetatable(obj, {
            __index = function(self, index)
                if _G[index] then
                    return (setmetatable({callback = _G[index]},
                        {__call = function(self, ...)
                            return self.callback(item.uid, ...)
                        end}
                    ))
                else
                    return UpgradeHandler[index]
                end
        end})

        if ret:isEquipment() then
            ret:update()
            return ret
        end
        return false
    end


    function UpgradeHandler:update()
       -- this will return the level by the quality or 0 if it has no quality.
        self.item.level = 0
		for r, v in ipairs(self.nameLv) do
		    if self:getItemName():find(v) then
		        self.item.level = r
		    end
		end
    end

    function UpgradeHandler:refine(uid, item)
        if not self.item then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.notupgradeable)
            return "miss"
        end

        local tool = self.tools[item.itemid]
        if(tool == nil) then
            doPlayerSendTextMessage(uid, MESSAGE_EVENT_DEFAULT, self.message.invalidtool)
            return "miss"
        end

        if(self.item.level > #self.levels) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.maxlevel:format(self.item.name))
            return "miss"
        end

        if(tool.range[1] and self.item.level < tool.range[1]) or (tool.range[2] and self.item.level >= tool.range[2]) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.toolrange:format(unpack(tool.range)))
            return "miss"
        end

        local chance = (self:chance().upgrade + tool.info.chance)
        doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.console:format(self.item.name, (self.item.level + 1), math.min(100, chance)))
        if(tool.info.removeable == true) then
            doRemoveItem(item.uid, 1)
        end

        if chance * 100 > math.random(1, 10000) then
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1)))
            if (self.item.level + 1) >= self.broadcast then
                doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1)))
            end
            -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more
            -- if the current level equals 0 add 1 to it
            self:setItemName(self.item.level > 0 and self.nameLv[self.item.level + 1].." "..(self:getItemName():gsub(self.nameLv[self.item.level].." ", "")) or self.nameLv[1].." "..self:getItemName())
            for key, value in pairs(self.attributes) do
                if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                    doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value)
                end
            end
            return "success"
        else
            if item.itemid == 8300 then
                if self.item.level > 0 then
                    -- this will remove any number with a + sign in front of it from the string
                    self:setItemName(self:getItemName():gsub((self.nameLv[self.item.level].." "), ""))
                    for key, value in pairs(self.attributes) do
                        if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then
                            doItemSetAttribute(self.item.uid, key, getItemAttribute(self.item.uid, key) - self.item.level * value)
                        end
                    end
                end
            else
                doRemoveItem(self.item.uid, 1)
            end
            doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, item.itemid == 8300 and "Your item level has been reseted." or "You have broken your item while trying to upgrade it.")
        end
    end

 

 

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

Link para o post
Compartilhar em outros sites
8 horas atrás, xWhiteWolf disse:

 

 

Não sei como te agradecer, muito obrigado mesmo... Não sei se ta funcionando ou se vai bugar, demorou muito pra esse bug aparecer...

Mas vlw por tudo aí!

 

Esse sistema de refinamento é mt compelxo pra mim, só faço scripts onsay tipo comprar algum item, um movemment, uma porta, não entendo mt ele...

Me tira uma dúvida...

 

Seria possivel integrar ele com esse sistema de trade offline de 8.6? O que eu precisaria saber pra poder fazer isso? Qlqr material q souber ou puder, script relacionado...

 

  --[[
        Offline player to player item trader (Auction System) by vDk
                Script version: 1.2a [ -- FIXED CLONE ITEMS BUG -- ]
]]--
local config = {
        levelRequiredToAdd = 50,
        maxOffersPerPlayer = 5,
        SendOffersOnlyInPZ = true,
        blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933}
        }
function onSay(cid, words, param, channel)
        if(param == '') then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
                return true
        end
 
        local t = string.explode(param, ",")
        if(t[1] == "add") then
                if((not t[2]) or (not t[3]) or (not t[4])) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
                        return true
                end          

                if(not tonumber(t[3]) or (not tonumber(t[4]))) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
                        return true
                end
 
                if(string.len(t[3]) > 7 or (string.len(t[4]) > 3)) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
                        return true
                end
 
                local item = getItemIdByName(t[2], false)
                if(not item) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
                        return true
                end
 
                if(getPlayerLevel(cid) < config.levelRequiredToAdd) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
                        return true
                end
 
                if(getPlayerVocation(cid) == 0) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have the profession to do that action!")
                        return true
                end

                if(isInArray(config.blocked_items, item)) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
                        return true
                end
 
                if(getPlayerItemCount(cid, item) < (tonumber(t[4]))) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
                        return true
                end
 
                local check = db.getResult("SELECT `id` FROM `auction_system` WHERE `player` = " .. getPlayerGUID(cid) .. ";")
                if(check:getID() == -1) then
                elseif(check:getRows(true) >= config.maxOffersPerPlayer) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max. " .. config.maxOffersPerPlayer .. ")")
                        return true
                end
 
                if(config.SendOffersOnlyInPZ) then    
                        if(not getTilePzInfo(getPlayerPosition(cid))) then
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                                return true
                        end
                end
 
                if(tonumber(t[4]) < 1 or (tonumber(t[3]) < 1)) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
                        return true
                end
 
                local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
                doPlayerRemoveItem(cid, item, itemcount)
                db.executeQuery("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. getPlayerGUID(cid) .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
        end
 
        if(t[1] == "buy") then
                if(not tonumber(t[2])) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
                        return true
                end
 
                local buy = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
                if(buy:getID() ~= -1) then
                        if(getPlayerMoney(cid) < buy:getDataInt("cost")) then
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh GP.")
                                buy:free()
                                return true
                        end
 
                        if(getPlayerName(cid) == getPlayerNameByGUID(buy:getDataInt("player"))) then
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                                buy:free()
                                return true
                        end
 
                        if(getPlayerFreeCap(cid) < getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")))then
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getDataString("item_name") .. ". It weight " .. getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                                buy:free()
                                return true
                        end

                        if(getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == 13 or getPlayerVocation(cid) == 14) then
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have the profession to do that action!")
                                return true
                        end
 
                        if(isItemStackable((buy:getDataString("item_id")))) then
                                doPlayerAddItem(cid, buy:getDataString("item_id"), buy:getDataInt("count"))
                        else
                                for i = 1, buy:getDataInt("count") do
                                        doPlayerAddItem(cid, buy:getDataString("item_id"), 1)
                                end
                        end
 
                        doPlayerRemoveMoney(cid, buy:getDataInt("cost"))
                        db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You bought " .. buy:getDataInt("count") .. " ".. buy:getDataString("item_name") .. " for " .. buy:getDataInt("cost") .. " gps!")
                        db.executeQuery("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getDataInt("cost") .. " WHERE `id` = " .. buy:getDataInt("player") .. ";")
                        buy:free()
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
                end
        end
 
        if(t[1] == "remove") then
                if((not tonumber(t[2]))) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
                        return true
                end
 
                                if(config.SendOffersOnlyInPZ) then    
                                        if(not getTilePzInfo(getPlayerPosition(cid))) then
                                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                                                return true
                                        end
                end
 
                local delete = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")        
                if(delete:getID() ~= -1) then
                        if(getPlayerGUID(cid) == delete:getDataInt("player")) then
                                db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                                if(isItemStackable(delete:getDataString("item_id"))) then
                                        doPlayerAddItem(cid, delete:getDataString("item_id"), delete:getDataInt("count"))
                                else
                                        for i = 1, delete:getDataInt("count") do
                                                doPlayerAddItem(cid, delete:getDataString("item_id"), 1)
                                        end
                                end
 
                                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
                        else
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
                        end
                delete:free()
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
                end
        end
 
        if(t[1] == "withdraw") then
                local balance = db.getResult("SELECT `auction_balance` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. ";")
                if(balance:getDataInt("auction_balance") < 1) then
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have money on your auction balance.")
                        balance:free()
                        return true
                end
 
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got " .. balance:getDataInt("auction_balance") .. " gps from auction system!")
                doPlayerAddMoney(cid, balance:getDataInt("auction_balance"))
                db.executeQuery("UPDATE `players` SET `auction_balance` = '0' WHERE `id` = " .. getPlayerGUID(cid) .. ";")
                balance:free()
        end
        return true
end 

 

 

m1m4mJw.png

Link para o post
Compartilhar em outros sites

vc quer q ele possa colocar e comprar itens UNIQ, EPIC e RARE?

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

Link para o post
Compartilhar em outros sites
Em 15/06/2016 at 10:30, xWhiteWolf disse:

vc quer q ele possa colocar e comprar itens UNIQ, EPIC e RARE?

 

Uhun... isso seria possivel ou daria algum problema? Pq esses itens refinados precisam ser salvos em algum lugar.. Sei lá não entendo quase nada, to começando ainda estudando logica de programação...

 

Esse ultimo script vc tirou aquela rates?

Tipo que configurava chance = 1, chance = 2

E multiplicava a chance em 2 vezes?

 

Pq eu tentei

 



--PERFECT UPGRADE SYSTEM UpgradeHandler = { nameLv = { [1] = "UNIQ", [2] = "RARE", [3] = "EPIC" }, levels = { [1] = {50, false, false}, [2] = {20, false, false}, [3] = {10, true, true} }, broadcast = 4, attributes = { ["attack"] = 3, ["defense"] = 2, ["armor"] = 1 }, message = { console = "Trying to refine %s to level +%s with %s%% success rate.", success = "You have upgraded %s to level +%s", fail = "You have failed in upgrade of %s to level +%s", downgrade = "The upgrade level of %s has downgraded to +%s", erase = "The upgrade level of %s has been erased.", maxlevel = "The targeted %s is already on max upgrade level.", notupgradeable = "This item is not upgradeable.", broadcast = "The player %s was successful in upgrading %s to level +%s.\nCongratulations!!", invalidtool = "This is not a valid upgrade tool.", toolrange = "This upgrade tool can only be used in items with level between +%s and +%s" }, tools = { [8306] = {range = {0, 10}, info = {chance = 1, removeable = true}}, [8300] = {range = {0, 10}, info = {chance = 2, removeable = true}} }, isEquipment = function(self) local weaponType = self:getItemWeaponType() return ((weaponType > 0 and weaponType < 7) or self.item.armor ~= 0) end, setItemName = function(self, name) return doItemSetAttribute(self.item.uid, "name", name) end, chance = function(self) local chances = {} chances.upgrade = (self.levels[self.item.level + 1][1] or 100) chances.downgrade = (self.item.level * 5) chances.erase = (self.item.level * 3) return chances end } function UpgradeHandler:new(item) local obj, ret = {} obj.item = {} obj.item.level = 0 obj.item.uid = item.uid for key, value in pairs(getItemInfo(item.itemid)) do obj.item[key] = value end ret = setmetatable(obj, { __index = function(self, index) if _G[index] then return (setmetatable({callback = _G[index]}, {__call = function(self, ...) return self.callback(item.uid, ...) end} )) else return UpgradeHandler[index] end end}) if ret:isEquipment() then ret:update() return ret end return false end function UpgradeHandler:update() -- this will return the level by the quality or 0 if it has no quality. self.item.level = 0 for r, v in ipairs(self.nameLv) do if self:getItemName():find(v) then self.item.level = r end end end function UpgradeHandler:refine(uid, item) if not self.item then doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.notupgradeable) return "miss" end local tool = self.tools[item.itemid] if(tool == nil) then doPlayerSendTextMessage(uid, MESSAGE_EVENT_DEFAULT, self.message.invalidtool) return "miss" end if(self.item.level > #self.levels) then doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.maxlevel:format(self.item.name)) return "miss" end if(tool.range[1] and self.item.level < tool.range[1]) or (tool.range[2] and self.item.level >= tool.range[2]) then doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.toolrange:format(unpack(tool.range))) return "miss" end local chance = (self:chance().upgrade + tool.info.chance) doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.console:format(self.item.name, (self.item.level + 1), math.min(100, chance))) if(tool.info.removeable == true) then doRemoveItem(item.uid, 1) end if chance * 100 > math.random(1, 10000) then doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1))) if (self.item.level + 1) >= self.broadcast then doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1))) end -- it says if the item's level is greater then 0 (meaning is level equal to 1 or more) if it is add 1 more -- if the current level equals 0 add 1 to it self:setItemName(self.item.level > 0 and self.nameLv[self.item.level + 1].." "..(self:getItemName():gsub(self.nameLv[self.item.level].." ", "")) or self.nameLv[1].." "..self:getItemName()) for key, value in pairs(self.attributes) do if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value) end end return "success" else if item.itemid == 8300 then if self.item.level > 0 then -- this will remove any number with a + sign in front of it from the string self:setItemName(self:getItemName():gsub((self.nameLv[self.item.level].." "), "")) for key, value in pairs(self.attributes) do if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then doItemSetAttribute(self.item.uid, key, getItemAttribute(self.item.uid, key) - self.item.level * value) end end end else doRemoveItem(self.item.uid, 1) end doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, item.itemid == 8300 and "Your item level has been reseted." or "You have broken your item while trying to upgrade it.") end end

 

 

E o item 8300 em vez de começar como 100% de chance (50 * 2, [1] = {50, false, false},)  parece que somou as porcentagens e ficou 52%

O outro item [8306] = {range = {0, 10}, info = {chance = 1, removeable = true}}, também, em vez de começar com 50%: [1] = {50, false, false}, começou com 51%

Editado por gmstrikker (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Conteúdo Similar

    • Por Jaurez
      .
    • Por Cat
      Em alguns casos, o tibia 8.60 comum não abre de jeito nenhum no map editor, mesmo desmarcando check file signatures e configurando o path corretamente.
       
      Este é o client 8.60 adaptado para o Remere's Map Editor. Resolvi postar já que ele foi removido do site oficial do RME. (ficou apenas a versão para linux lá)
      Se estiver tendo problemas para abrir a versão 8.60, tente utilizar este.
                                                                                                                     
      Baixar o Tibia Client 8.60 que funciona no Remere’s Map Editor
      Essa versão do Tibia 8.60 client resolve o erro unsupported client version ou Could not locate tibia.dat and/or tibia.spr, please navigate to your tibia 8.60 installation folder.
       
      Downloads
      https://tibiaking.com/applications/core/interface/file/attachment.php?id=47333

      Scan: https://www.virustotal.com/gui/file/333e172ac49ba2028db9eb5889994509e7d2de28ebccfa428c04e86defbe15cc
       
    • Por danilo belato
      Fala Galera To Com um problema aki 
       
      quero exporta umas sprites de um server para colocar em outro 
       
      eu clico na sprites ai aparece tds a forma delas do lado de la >>
       
      ai eu clico nela e ponho a opiçao de export mais quando salvo a sprite ela n abri 
       
      aparece isso quando tento vê-la 
       
      visualização não disponível ( no formatos png e bitmap)
       
      Agora no formato idc fala que o paint n pode ler 
       
      me ajudem ae...
    • Por Vitor Bicaleto
      Galera to com o script do addon doll aqui, quando eu digito apenas "!addon" ele aparece assim: Digite novamente, algo está errado!"
      quando digito por exemplo: "!addon citizen" ele não funciona e não da nenhum erro
       
      mesma coisa acontece com o mount doll.. 
    • Por Ayron5
      Substitui uma stone no serve, deu tudo certo fora  esse  erro ajudem  Valendo  Rep+  Grato  

      Erro: data/actions/scripts/boost.lua:557: table index is nil
       [Warning - Event::loadScript] Cannot load script (data/actions/scripts/boost.lua)

      Script:
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo