Ir para conteúdo

Featured Replies

Postado

Olá estou com esse script do LeoTk  sobre box

Gostaria que ele só trabalhasse com o ID 2362, mas quando faço as modificações como está abaixo a box não abre, alguém ajuda ae!

local items = {
  {itemId = 2362, count = 1, chance = 30}, -- ITEM, QUANTIDADE, CHANCE
  {itemId = 2362, count = 10, chance = 25},
  {itemId = 2362, count = 20, chance = 20},
  {itemId = 2362, count = 30, chance = 15},
  {itemId = 2362, count = 40, chance = 10},   
  {itemId = 2362, count = 50, chance = 5},
  {itemId = 2361, count = 1, chance = 1},     
}
local broadcastitems = {2361}

function onUse(cid, item, frompos, item2, topos)

  local totalChance, randomTable, randomNumber = 0, {}, 0

  for _, itemInfo in pairs (items) do
    randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1}
    totalChance = totalChance + itemInfo.chance
  end

  randomNumber = math.random(1, totalChance)
  for itemId, itemInfo in pairs (randomTable) do
    local min, max = itemInfo.min, itemInfo.min + itemInfo.max
    if randomNumber >= min and randomNumber <= max then
      local newItem = doPlayerAddItem(cid, itemId, itemInfo.count, false)
      if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end
      doPlayerRemoveItem(cid, 1990, 1)
	  local pos = {x=getPlayerPosition(cid).x+0, y=getPlayerPosition(cid).y+0, z=getPlayerPosition(cid).z+0}
	  doSendMagicEffect(pos, 684) -- Id do efeito.
      local iInfo = getItemInfo(itemId)
      doPlayerSendTextMessage(cid, 25, "Voce ganhou "..itemInfo.count.." "..iInfo.name.."")
      for i, broaditem in ipairs(broadcastitems) do
        if itemId==broaditem then doBroadcastMessage(getCreatureName(cid).." acabou de ganhar: "..itemInfo.count.." "..iInfo.name.." (Raro) na presente box.", 19) end
      end
      break
    end
  end
  return true
end

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

Postado
local items = {
  {itemId = 2362, count = 1, chance = 30}, -- ITEM, QUANTIDADE, CHANCE
  {itemId = 2361, count = 10, chance = 1}, 
}
local broadcastitems = {2361}

function onUse(cid, item, frompos, item2, topos)

  local totalChance, randomTable, randomNumber = 0, {}, 0

  for _, itemInfo in pairs (items) do
    randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1}
    totalChance = totalChance + itemInfo.chance
  end

  randomNumber = math.random(1, totalChance)
  for itemId, itemInfo in pairs (randomTable) do
    local min, max = itemInfo.min, itemInfo.min + itemInfo.max
    if randomNumber >= min and randomNumber <= max then
      local newItem = doPlayerAddItem(cid, itemId, itemInfo.count, false)
      if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end
      doPlayerRemoveItem(cid, 1990, 1)
	  local pos = {x=getPlayerPosition(cid).x+0, y=getPlayerPosition(cid).y+0, z=getPlayerPosition(cid).z+0}
	  doSendMagicEffect(pos, 684) -- Id do efeito.
      local iInfo = getItemInfo(itemId)
      doPlayerSendTextMessage(cid, 25, "Voce ganhou "..itemInfo.count.." "..iInfo.name.."")
      for i, broaditem in ipairs(broadcastitems) do
        if itemId==broaditem then doBroadcastMessage(getCreatureName(cid).." acabou de ganhar: "..itemInfo.count.." "..iInfo.name.." (Raro) na presente box.", 19) end
      end
      break
    end
  end
  return true
end

@XGaduX testa assim

Projeto ATS (Naruto)

Informações Abaixo

Facebook

Youtube
Discord

 

Tutoriais / Conteúdos

Clique Aqui

Postado
  • Autor
  Em 04/01/2020 em 03:48, LeoTK disse:

local items = {
  {itemId = 2362, count = 1, chance = 30}, -- ITEM, QUANTIDADE, CHANCE
  {itemId = 2361, count = 10, chance = 1}, 
}
local broadcastitems = {2361}

function onUse(cid, item, frompos, item2, topos)

  local totalChance, randomTable, randomNumber = 0, {}, 0

  for _, itemInfo in pairs (items) do
    randomTable[itemInfo.itemId] = {min = totalChance + 1, max = itemInfo.chance, count = itemInfo.count or 1}
    totalChance = totalChance + itemInfo.chance
  end

  randomNumber = math.random(1, totalChance)
  for itemId, itemInfo in pairs (randomTable) do
    local min, max = itemInfo.min, itemInfo.min + itemInfo.max
    if randomNumber >= min and randomNumber <= max then
      local newItem = doPlayerAddItem(cid, itemId, itemInfo.count, false)
      if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end
      doPlayerRemoveItem(cid, 1990, 1)
	  local pos = {x=getPlayerPosition(cid).x+0, y=getPlayerPosition(cid).y+0, z=getPlayerPosition(cid).z+0}
	  doSendMagicEffect(pos, 684) -- Id do efeito.
      local iInfo = getItemInfo(itemId)
      doPlayerSendTextMessage(cid, 25, "Voce ganhou "..itemInfo.count.." "..iInfo.name.."")
      for i, broaditem in ipairs(broadcastitems) do
        if itemId==broaditem then doBroadcastMessage(getCreatureName(cid).." acabou de ganhar: "..itemInfo.count.." "..iInfo.name.." (Raro) na presente box.", 19) end
      end
      break
    end
  end
  return true
end

@XGaduX testa assim

 

funcionou!, mas meu objetivo era que fosse por packs tipo 
 

{itemId = 2362, count = 100, chance = 1},

{itemId = 2362, count = 90, chance = 10},

{itemId = 2362, count = 80, chance = 20},

{itemId = 2362, count = 70, chance = 30},     etc...

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.7k

Informação Importante

Confirmação de Termo