Ir para conteúdo

Featured Replies

Postado

tem que resolver agora cara, se não funcionar me manda o print doque aparece, seja o erro no console ou a mensagem que aparece pro player

local vocations = {11, 16, 21}

local ids_bloqueados = {2160, 5706, 7893, 7892, 7894, 7895, 7896, 7897, 7898, 7899, 7901, 7902, 2640, 6132, 2195, 9932, 9933, 11350, 11297, 3982, 8857, 8855, 8856, 7438, 8858, 8854, 2456, 7366, 5907, 3965, 7378, 2389, 7367, 7368, 2425, 9932}

local controle = {
    {level = 0, quantOre = 1, chance = 48},
    {level = 1, quantOre = 2, chance = 33},
    {level = 2, quantOre = 3, chance = 28},
    {level = 3, quantOre = 4, chance = 27},
    {level = 4, quantOre = 5, chance = 24},
    {level = 5, quantOre = 6, chance = 20},
    {level = 6, quantOre = 7, chance = 10},
    {level = 7, quantOre = 8, chance = 8},
    {level = 8, quantOre = 9, chance = 5},
    {level = 9, quantOre = 10, chance = 2}
}

function getItemLevel(uid)
    if uid > 0 then
        return getItemAttribute(uid, "lvl") or 0
    end
    return false
end

function doItemAddLevel(uid, count)
    if uid > 0 and tonumber(count) > 0 then
        return doItemSetAttribute(uid, "lvl", getItemLevel(uid) + count)
    end
    return false
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not isInArray(vocations, getPlayerVocation(cid)) then
		doPlayerSendCancel(cid, "Apenas blacksmiths podem refinar.")
    return false
	end
	
    if isInArray(ids_bloqueados, itemEx.itemid) then
        doPlayerSendCancel(cid, "Este item nao pode ser refinado.")
	return false
    end 
    
    if getItemInfo(itemEx.itemid).attack > 0 or getItemInfo(itemEx.itemid).defense > 0 or getItemInfo(itemEx.itemid).armor > 0 then
        for _, upgrade in pairs(controle) do
            local atk = getItemAttribute(itemEx.uid, "attack") or getItemInfo(itemEx.itemid).attack
            local def = getItemAttribute(itemEx.uid, "defense") or getItemInfo(itemEx.itemid).defense
            local arm = getItemAttribute(itemEx.uid, "armor") or getItemInfo(itemEx.itemid).armor
            local chance = math.random(1, 100)
            if getItemLevel(itemEx.uid) == upgrade.level then
               if doPlayerRemoveItem(cid, 5880, upgrade.quantOre) then
                   doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_CRAPS)
                  if chance <= upgrade.chance then
                      if getItemLevel(itemEx.uid) == 0 then
                          doItemSetAttribute(itemEx.uid, "description", "Esse item foi refinado por " ..getCreatureName(cid))
                      end
                      doItemAddLevel(itemEx.uid, 1)
                      doItemSetAttribute(itemEx.uid, "name", getItemNameById(itemEx.itemid).. " + " ..getItemLevel(itemEx.uid))
                      doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voce refinou com sucesso!")
                      if atk > 0 then
                          doItemSetAttribute(itemEx.uid, "attack", atk + 1)
                          return true
                      elseif arm > 0 then
                          doItemSetAttribute(itemEx.uid, "armor", arm + 1)
                          return true
                      elseif def > 0 then
                          doItemSetAttribute(itemEx.uid, "defense", def + 1)
                          return true
                      end
                  else
                      doTransformItem(itemEx.uid, 2256)
                      doItemSetAttribute(itemEx.uid, 'name', "metal trash")
                      doItemSetAttribute(itemEx.uid, 'attack', 0)
                      doItemSetAttribute(itemEx.uid, 'armor', 0)
                      doItemSetAttribute(itemEx.uid, 'defense', 0)
                      doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voce falhou.")
                      return true
                  end
              else
                  doPlayerSendCancel(cid, "Voce nao tem iron ores o suficiente. Voce precisa de "..upgrade.quantOre.." iron ores.")
              end
          end
      end
  else
      doPlayerSendCancel(cid, "Esse item nao pode ser refinado.")
  end
  return true
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)

  • Respostas 10
  • Visualizações 865
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • detesto ficar corrigindo script dos outros mas em todo caso: Acho que agora vai.

  • testa assim e me diz se resolve local vocations = {11, 16, 21} local ids_bloqueados = {2160, 5706, 7893, 7892, 7894, 7895, 7896, 7897, 7898, 7899, 7901, 7902, 2640, 6132, 2195, 9932, 9933, 11350,

  • actions.

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo