Ir para conteúdo

alguém poderia "consertar" esse scrip para mim? (quando o player usar ele, a função remover não é ativada fazendo que o player abra a box infinitamente)

Featured Replies

Postado

(alguém poderia "consertar" esse scrip para mim? (quando o player usar ele, a função remover não é ativada fazendo que o player abra a box infinitamente))


local items = {
  {itemId = 12779, count = 1, chance = 1},
  {itemId = 12780, count = 2, chance = 99},
}
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, qntItemsByPercnt(), false)
      if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end
      local pos = {x=getPlayerPosition(cid).x+0, y=getPlayerPosition(cid).y+0, z=getPlayerPosition(cid).z+0}
      doSendMagicEffect(pos, 442)
      local iInfo = getItemInfo(itemId)
      doPlayerSendTextMessage(cid, 19, "Voce ganhou "..iInfo.name.."")
      for i, broaditem in ipairs(broadcastitems) do
        if itemId==broaditem then doBroadcastMessage(getCreatureName(cid).." acabou de ganhar  "..iInfo.name.." (Raro) na senzu box.", 19) end
      end
      break
    end
  end

doRemoveItem(item.uid, 1)
  return true
end

 

  • Respostas 11
  • Visualizações 719
  • Created
  • Última resposta

Top Posters In This Topic

Postado
local items = {
  {itemId = 12779, count = 1, chance = 1},
  {itemId = 12780, count = 2, chance = 99},
}

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
            doRemoveItem(item.uid, 1)
            local newItem = doPlayerAddItem(cid, itemId, qntItemsByPercnt(), false)
            if not newItem then 
                return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") 
            end

            local pos = {x=getPlayerPosition(cid).x+0, y=getPlayerPosition(cid).y+0, z=getPlayerPosition(cid).z+0}
            doSendMagicEffect(pos, 442)
            local iInfo = getItemInfo(itemId)
            doPlayerSendTextMessage(cid, 19, "Voce ganhou "..iInfo.name.."")
            for i, broaditem in ipairs(broadcastitems) do
                if itemId==broaditem then 
                    doBroadcastMessage(getCreatureName(cid).." acabou de ganhar  "..iInfo.name.." (Raro) na senzu box.", 19) 
                end
            end
        break
        end
    end

return true
end

 

 

Projeto/Serviços que desenvolvi durante esse Tempo.

[SERVIDOR] - NTO By Madara Rinnegan - Criado em 2014

Postado
  • Autor
4 minutos atrás, Onepiece disse:

local items = {
  {itemId = 12779, count = 1, chance = 1},
  {itemId = 12780, count = 2, chance = 99},
}

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
            doRemoveItem(item.uid, 1)
            local newItem = doPlayerAddItem(cid, itemId, qntItemsByPercnt(), false)
            if not newItem then 
                return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") 
            end

            local pos = {x=getPlayerPosition(cid).x+0, y=getPlayerPosition(cid).y+0, z=getPlayerPosition(cid).z+0}
            doSendMagicEffect(pos, 442)
            local iInfo = getItemInfo(itemId)
            doPlayerSendTextMessage(cid, 19, "Voce ganhou "..iInfo.name.."")
            for i, broaditem in ipairs(broadcastitems) do
                if itemId==broaditem then 
                    doBroadcastMessage(getCreatureName(cid).." acabou de ganhar  "..iInfo.name.." (Raro) na senzu box.", 19) 
                end
            end
        break
        end
    end

return true
end

 



Então, testei aqui continua mesma coisa... a box fica "infinita" 

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.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 520.2k

Informação Importante

Confirmação de Termo