Postado Junho 16, 2022 2 anos Autor Bom dia, poderia dar uma olhada pra mim se tem algo errado por favor? Nao consegui achar a função de alterar item, coloquei de adicionar, mas acho que esta errado e nao vai dar certo. Citar local forge = Action() local count = 1 local item = 24963 local porcentagem = 100 -- porcentagem de chance de forjar local chance = { -- cada id significa 10% de chance de acerto { id = 10}, { id = 20}, { id = 30}, { id = 40}, { id = 50}, { id = 60}, { id = 70}, { id = 80}, { id = 90}, { id = 100} } function forge.onUse(player, item, fromPosition, target, toPosition, isHotkey) local randId = math.random(1, #chance) local rewardItem = chance[randId] if item:getCount(item) < (count) then player:sendTextMessage(MESSAGE_STATUS_SMALL, "Voce nao tem a quantidade de items necessaria para forjar") player:getPosition():sendMagicEffect(CONST_ME_POFF) return end local split = param:split(",") local itemType = ItemType(split[1]) if target.itemType:getId() == 0 then porcentagem = 100 else if target.itemType:getId() == 1 then porcentagem = 90 else if target.itemType:getId() == 2 then porcentagem = 80 else if target.itemType:getId() == 3 then porcentagem = 70 else if target.itemType:getId() == 4 then porcentagem = 60 else if target.itemType:getId() == 5 then porcentagem = 50 else if target.itemType:getId() == 6 then porcentagem = 40 else if target.itemType:getId() == 7 then porcentagem = 30 else if target.itemType:getId() == 8 then porcentagem = 20 else if target.itemType:getId() == 9 then porcentagem = 10 else if target.itemType:getId() == nil then player:sendTextMessage(MESSAGE_STATUS_SMALL, "Este nao e um item Forjavel.") player:getPosition():sendMagicEffect(CONST_ME_POFF) return end end end end end end end end end end end if chance.id <= (porcentagem) then itemType:remove(count) player:addItem(target.itemType:getId(), 1):setTier(tier) player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Parabens, o item foi forjado.") player:getPosition():sendMagicEffect(50) else itemType:remove(count) player:sendTextMessage(MESSAGE_STATUS_SMALL, "Sua forja falhou. Voce perdeu os items de forja.") player:getPosition():sendMagicEffect(CONST_ME_POFF) return end end forge:id(24963) forge:register() Editado Junho 16, 2022 2 anos por Pacera (veja o histórico de edições)
Postado Junho 20, 2022 2 anos local forge = Action() local count = 1 local porcentagem = 100 -- porcentagem de chance de forjar local chance = { -- cada id significa 10% de chance de acerto [1] = 100, [2] = 90, [3] = 80, [4] = 70, [5] = 60, [6] = 50, [7] = 40, [8] = 30, [9] = 20, [10] = 10 } function forge.onUse(player, item, fromPosition, target, toPosition, isHotkey) if not target or not target:isItem() then return false end local targetId = target:getId() local targetTier = target:getTier() if not targetTier then player:sendTextMessage(MESSAGE_STATUS_SMALL, "Este nao e um item Forjavel.") player:getPosition():sendMagicEffect(CONST_ME_POFF) return true end if not target:remove(count) then player:sendTextMessage(MESSAGE_STATUS_SMALL, "Voce nao tem a quantidade de items necessaria para forjar") player:getPosition():sendMagicEffect(CONST_ME_POFF) return true end local rand = math.random(100) local chanceTier = target:getTier() and target:getTier() or 0 if rand > chance[chanceTier] then player:sendTextMessage(MESSAGE_STATUS_SMALL, "Voce forja falhou") player:getPosition():sendMagicEffect(CONST_ME_POFF) return true end if target:setTier(targetTier + 1) then player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Parabens, o item foi forjado.") player:getPosition():sendMagicEffect(50) end return true end forge:id(24963) forge:register()
Postado Junho 20, 2022 2 anos Autor Obrigado Ola, estou tendo erro na source ao usar em items como: potions, runas, gold coin ou items nao forjaveis. qd o item é tier 0 da o mesmo erro. [error] Lua script error: scriptInterface: [Scripts Interface] scriptId: [C:\Program Files (x86)\canary-global-windows-x64-full\data\scripts\custom\forja.lua:callback] timerEvent: [] callbackId:[] function: [] error [...ry-global-windows-x64-full\data\scripts\custom\forja.lua:49: attempt to compare nil with number stack traceback: [C]: in function '__lt' ...ry-global-windows-x64-full\data\scripts\custom\forja.lua:49: in function <...ry-global-windows-x64-full\data\scripts\custom\forja.lua:18>] Editado Junho 20, 2022 2 anos por Pacera (veja o histórico de edições)
Postado Junho 20, 2022 2 anos É o que eu disse aqui: Em 15/06/2022 em 15:50, luanluciano93 disse: - verificação se o target é um item válido Você tem que ver uma forma de como fazer isso ... quais os tipos de itens aceitar ou não, eu não conheço o sistema, já te dei quase tudo pronto.
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.