Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Abir a box, se receber o item id 2160 (configuravel para add novos itens) aparece um broadcast para todos do servidor: Ricardo acabou de receber "quantidade" "nome do item" da mystery box.

 

Exemplo:

doBroadcastMessage(""..getCreatureName(cid).." acabou de ganhar: "..i.quant.." item(s) "..getItemNameById(_).." na Mystery Box.")

 

mysterybox.lua 

Spoiler

local items = {
{itemId = 2160, count = 1, chance = 50}, -- ITEM, QUANTIDADE, CHANCE
{itemId = 2152, count = 1, chance = 50},
{itemId = 2148, count = 1, chance = 70},
}

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

local config = {
	pos = getCreaturePosition(cid), -- posição do player
	exhaustionSeconds = 3600, -- exausted em segundos
	storageUse = 44231, -- storage usado.

}

if(exhaustion.check(cid, config.storageUse)) then
if (exhaustion.get(cid, config.storageUse) >= 60) then
doPlayerSendCancel(cid, "Voce so poderar abrir o bau novamente em " .. math.floor(exhaustion.get(cid, config.storageUse) / 60 + 1) .." minutos.") 
end
if (exhaustion.get(cid, config.storageUse) <= 60) then
doPlayerSendCancel(cid, "Voce precisa esperar " .. exhaustion.get(cid, config.storageUse).." segundos.")
end
return true
end

    local totalChance, randomTable, randomNumber = 0, {}, 0
	
	addEvent(doPlayerSendTextMessage, 1*1000, cid, 27, "Procurando algo...")
    addEvent(doPlayerSendTextMessage, 2*1000, cid, 27, "Procurando algo...")
	addEvent(doPlayerSendTextMessage, 3*1000, cid, 27, "Procurando algo...")
	addEvent(doPlayerSendTextMessage, 4*1000, cid, 27, "Procurando algo...")
	addEvent(doPlayerSendTextMessage, 5*1000, cid, 27, "Procurando algo...")
	addEvent(doSendAnimatedText, 1*1000, config.pos, "[5]", 180)
    addEvent(doSendAnimatedText, 2*1000, config.pos, "[4]", 180)
	addEvent(doSendAnimatedText, 3*1000, config.pos, "[3]", 180)
	addEvent(doSendAnimatedText, 4*1000, config.pos, "[2]", 180)
	addEvent(doSendAnimatedText, 5*1000, config.pos, "[1]", 180)
	addEvent(doSendAnimatedText, 6*1000, config.pos, "DONE!", 180)
	
    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 = addEvent(doPlayerAddItem, 6*1000, cid, itemId, itemInfo.count, false)
                    if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end
                    doRemoveItem(item.uid, 0)
					exhaustion.set(cid, config.storageUse, config.exhaustionSeconds)
                    local iInfo = getItemInfo(itemId)
                    addEvent(doPlayerSendTextMessage, 6*1000, cid, 27, "Voce achou ("..iInfo.name..")!")
                    break
            end
    end

return true
end

 

 

Link para o post
Compartilhar em outros sites

mysterybox.lua:

Spoiler

local items = {
{itemId = 2160, count = 1, chance = 50}, -- ITEM, QUANTIDADE, CHANCE
{itemId = 2152, count = 1, chance = 50},
{itemId = 2148, count = 1, chance = 70},
}

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

local config = {
	pos = getCreaturePosition(cid), -- posição do player
	exhaustionSeconds = 3600, -- exausted em segundos
	storageUse = 44231, -- storage usado.

}

if(exhaustion.check(cid, config.storageUse)) then
if (exhaustion.get(cid, config.storageUse) >= 60) then
doPlayerSendCancel(cid, "Voce so poderar abrir o bau novamente em " .. math.floor(exhaustion.get(cid, config.storageUse) / 60 + 1) .." minutos.") 
end
if (exhaustion.get(cid, config.storageUse) <= 60) then
doPlayerSendCancel(cid, "Voce precisa esperar " .. exhaustion.get(cid, config.storageUse).." segundos.")
end
return true
end

    local totalChance, randomTable, randomNumber = 0, {}, 0
	
	addEvent(doPlayerSendTextMessage, 1*1000, cid, 27, "Procurando algo...")
    addEvent(doPlayerSendTextMessage, 2*1000, cid, 27, "Procurando algo...")
	addEvent(doPlayerSendTextMessage, 3*1000, cid, 27, "Procurando algo...")
	addEvent(doPlayerSendTextMessage, 4*1000, cid, 27, "Procurando algo...")
	addEvent(doPlayerSendTextMessage, 5*1000, cid, 27, "Procurando algo...")
	addEvent(doSendAnimatedText, 1*1000, config.pos, "[5]", 180)
    addEvent(doSendAnimatedText, 2*1000, config.pos, "[4]", 180)
	addEvent(doSendAnimatedText, 3*1000, config.pos, "[3]", 180)
	addEvent(doSendAnimatedText, 4*1000, config.pos, "[2]", 180)
	addEvent(doSendAnimatedText, 5*1000, config.pos, "[1]", 180)
	addEvent(doSendAnimatedText, 6*1000, config.pos, "DONE!", 180)
	
    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 = addEvent(doPlayerAddItem, 6*1000, cid, itemId, itemInfo.count, false)
                    if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end
                    doRemoveItem(item.uid, 0)
					exhaustion.set(cid, config.storageUse, config.exhaustionSeconds)
                    local iInfo = getItemInfo(itemId)
      				if itemId == 2160 then
        				addEvent(doBroadcastMessage, 6*1000, getCreatureName(cid) .. " recebeu NOMEDOITEM.")
        			end
                    addEvent(doPlayerSendTextMessage, 6*1000, cid, 27, "Voce achou ("..iInfo.name..")!")
                    break
            end
    end

return true
end

 

 

OBS: Não cheguei a testar!!

Link para o post
Compartilhar em outros sites

tu pode testar assim tb, n testei, aí é só por em broadcastitems os id q vai dar broadcast eu coloquei 2160, 2161 ali soh de exemplo, muda com os q vc qr e adiciona mais colocando virgula

Spoiler




local items = {
  {itemId = 2160, count = 1, chance = 50}, -- ITEM, QUANTIDADE, CHANCE
  {itemId = 2152, count = 1, chance = 50},
  {itemId = 2148, count = 1, chance = 70},
}
local broadcastitems = {2160, 2161}

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

  local config = {
    pos = getCreaturePosition(cid), -- posição do player
    exhaustionSeconds = 3600, -- exausted em segundos
    storageUse = 44231, -- storage usado.

  }

  if(exhaustion.check(cid, config.storageUse)) then
    if (exhaustion.get(cid, config.storageUse) >= 60) then
      doPlayerSendCancel(cid, "Voce so poderar abrir o bau novamente em " .. math.floor(exhaustion.get(cid, config.storageUse) / 60 + 1) .." minutos.")
    end
    if (exhaustion.get(cid, config.storageUse) <= 60) then
      doPlayerSendCancel(cid, "Voce precisa esperar " .. exhaustion.get(cid, config.storageUse).." segundos.")
    end
    return true
  end

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

  addEvent(doPlayerSendTextMessage, 1*1000, cid, 27, "Procurando algo...")
  addEvent(doPlayerSendTextMessage, 2*1000, cid, 27, "Procurando algo...")
  addEvent(doPlayerSendTextMessage, 3*1000, cid, 27, "Procurando algo...")
  addEvent(doPlayerSendTextMessage, 4*1000, cid, 27, "Procurando algo...")
  addEvent(doPlayerSendTextMessage, 5*1000, cid, 27, "Procurando algo...")
  addEvent(doSendAnimatedText, 1*1000, config.pos, "[5]", 180)
  addEvent(doSendAnimatedText, 2*1000, config.pos, "[4]", 180)
  addEvent(doSendAnimatedText, 3*1000, config.pos, "[3]", 180)
  addEvent(doSendAnimatedText, 4*1000, config.pos, "[2]", 180)
  addEvent(doSendAnimatedText, 5*1000, config.pos, "[1]", 180)
  addEvent(doSendAnimatedText, 6*1000, config.pos, "DONE!", 180)

  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 = addEvent(doPlayerAddItem, 6*1000, cid, itemId, itemInfo.count, false)
      if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end
      doRemoveItem(item.uid, 0)
      exhaustion.set(cid, config.storageUse, config.exhaustionSeconds)
      local iInfo = getItemInfo(itemId)
      addEvent(doPlayerSendTextMessage, 6*1000, cid, 27, "Voce achou ("..iInfo.name..")!")
      for i, broaditem in ipairs(broadcastitems) do
        if itemId==broaditem then doBroadcastMessage(""..getCreatureName(cid).." acabou de ganhar: "..iInfo.name.." na Mystery Box.")end
      end
      break
    end
  end
  return true
end


 

 

n coloquei quantidade, ia ter q usar 1 array pra cada item ou storage

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

Life is so meaningless, there is nothing worth a smile
So goodbye, I'll miss you

 

 

sugestões?

 

 

Link para o post
Compartilhar em outros sites
3 minutos atrás, rogaforyn2 disse:

tu pode testar assim tb, n testei, aí é só por em broadcastitems os id q vai dar broadcast eu coloquei 2160, 2161 ali soh de exemplo, muda com os q vc qr e adiciona mais colocando virgula

 



local items = {
  {itemId = 2160, count = 1, chance = 50}, -- ITEM, QUANTIDADE, CHANCE
  {itemId = 2152, count = 1, chance = 50},
  {itemId = 2148, count = 1, chance = 70},
}
local broadcastitems = {2160, 2161}

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

  local config = {
    pos = getCreaturePosition(cid), -- posição do player
    exhaustionSeconds = 3600, -- exausted em segundos
    storageUse = 44231, -- storage usado.

  }

  if(exhaustion.check(cid, config.storageUse)) then
    if (exhaustion.get(cid, config.storageUse) >= 60) then
      doPlayerSendCancel(cid, "Voce so poderar abrir o bau novamente em " .. math.floor(exhaustion.get(cid, config.storageUse) / 60 + 1) .." minutos.")
    end
    if (exhaustion.get(cid, config.storageUse) <= 60) then
      doPlayerSendCancel(cid, "Voce precisa esperar " .. exhaustion.get(cid, config.storageUse).." segundos.")
    end
    return true
  end

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

  addEvent(doPlayerSendTextMessage, 1*1000, cid, 27, "Procurando algo...")
  addEvent(doPlayerSendTextMessage, 2*1000, cid, 27, "Procurando algo...")
  addEvent(doPlayerSendTextMessage, 3*1000, cid, 27, "Procurando algo...")
  addEvent(doPlayerSendTextMessage, 4*1000, cid, 27, "Procurando algo...")
  addEvent(doPlayerSendTextMessage, 5*1000, cid, 27, "Procurando algo...")
  addEvent(doSendAnimatedText, 1*1000, config.pos, "[5]", 180)
  addEvent(doSendAnimatedText, 2*1000, config.pos, "[4]", 180)
  addEvent(doSendAnimatedText, 3*1000, config.pos, "[3]", 180)
  addEvent(doSendAnimatedText, 4*1000, config.pos, "[2]", 180)
  addEvent(doSendAnimatedText, 5*1000, config.pos, "[1]", 180)
  addEvent(doSendAnimatedText, 6*1000, config.pos, "DONE!", 180)

  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 = addEvent(doPlayerAddItem, 6*1000, cid, itemId, itemInfo.count, false)
      if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end
      doRemoveItem(item.uid, 0)
      exhaustion.set(cid, config.storageUse, config.exhaustionSeconds)
      local iInfo = getItemInfo(itemId)
      addEvent(doPlayerSendTextMessage, 6*1000, cid, 27, "Voce achou ("..iInfo.name..")!")
      for i, broaditem in ipairs(broadcastitems) do
        if itemId==broaditem then doBroadcastMessage(""..getCreatureName(cid).." acabou de ganhar: "..iInfo.name.." na Mystery Box.")end
      end
      break
    end
  end
  return true
end

 

n coloquei quantidade, ia ter q usar 1 array pra cada item ou storage

Gostei bastante desse formato, fiz o teste e tem um problema, ele está avisando que o player ganhou o item raro no caso (2160) antes da contagem de 5 segundos.

Link para o post
Compartilhar em outros sites

Esqueci do addevent pera aí

Spoiler


local items = {
  {itemId = 2160, count = 1, chance = 50}, -- ITEM, QUANTIDADE, CHANCE
  {itemId = 2152, count = 1, chance = 50},
  {itemId = 2148, count = 1, chance = 70},
}
local broadcastitems = {2160, 2161}

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

  local config = {
    pos = getCreaturePosition(cid), -- posição do player
    exhaustionSeconds = 3600, -- exausted em segundos
    storageUse = 44231, -- storage usado.

  }

  if(exhaustion.check(cid, config.storageUse)) then
    if (exhaustion.get(cid, config.storageUse) >= 60) then
      doPlayerSendCancel(cid, "Voce so poderar abrir o bau novamente em " .. math.floor(exhaustion.get(cid, config.storageUse) / 60 + 1) .." minutos.")
    end
    if (exhaustion.get(cid, config.storageUse) <= 60) then
      doPlayerSendCancel(cid, "Voce precisa esperar " .. exhaustion.get(cid, config.storageUse).." segundos.")
    end
    return true
  end

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

  addEvent(doPlayerSendTextMessage, 1*1000, cid, 27, "Procurando algo...")
  addEvent(doPlayerSendTextMessage, 2*1000, cid, 27, "Procurando algo...")
  addEvent(doPlayerSendTextMessage, 3*1000, cid, 27, "Procurando algo...")
  addEvent(doPlayerSendTextMessage, 4*1000, cid, 27, "Procurando algo...")
  addEvent(doPlayerSendTextMessage, 5*1000, cid, 27, "Procurando algo...")
  addEvent(doSendAnimatedText, 1*1000, config.pos, "[5]", 180)
  addEvent(doSendAnimatedText, 2*1000, config.pos, "[4]", 180)
  addEvent(doSendAnimatedText, 3*1000, config.pos, "[3]", 180)
  addEvent(doSendAnimatedText, 4*1000, config.pos, "[2]", 180)
  addEvent(doSendAnimatedText, 5*1000, config.pos, "[1]", 180)
  addEvent(doSendAnimatedText, 6*1000, config.pos, "DONE!", 180)

  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 = addEvent(doPlayerAddItem, 6*1000, cid, itemId, itemInfo.count, false)
      if not newItem then return doPlayerSendCancel(cid, "Voce nao tem espaco para receber o item!") end
      doRemoveItem(item.uid, 0)
      exhaustion.set(cid, config.storageUse, config.exhaustionSeconds)
      local iInfo = getItemInfo(itemId)
      addEvent(doPlayerSendTextMessage, 6*1000, cid, 27, "Voce achou ("..iInfo.name..")!")
      for i, broaditem in ipairs(broadcastitems) do
        if itemId==broaditem then addEvent(doBroadcastMessage, 6*1000, getCreatureName(cid).." acabou de ganhar: "..iInfo.name.." na Mystery Box.") end
      end
      break
    end
  end
  return true
end

 

 

Life is so meaningless, there is nothing worth a smile
So goodbye, I'll miss you

 

 

sugestõ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