Ir para conteúdo

Featured Replies

Postado

como que eu faço para que esse script mandar msg no Broadcast quando conseguir tal item? tentei mudar algumas coisas mas nada =/

TFS:0.3.6

Obs: o script ta pra mandar a msg mas n ta indo alguem ai ajuda?

Spoiler

local items = {
  {itemId = 12337, count = 1, chance = 30}, -- naruto and gamabunta
  {itemId = 11987, count = 1, chance = 20}, -- naruto road to ninja
  {itemId = 12338, count = 1, chance = 20},
  {itemId = 12032, count = 1, chance = 20},
  {itemId = 12031, count = 1, chance = 20},   
  {itemId = 12030, count = 1, chance = 20},
  {itemId = 12547, count = 1, chance = 10},
  {itemId = 15685, count = 1, chance = 1},     
}
local broadcastitems = {12337, 11987, 12338}

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 the        n
      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, 11753, 1)
      local pos = {x=getPlayerPosition(cid).x+0, y=getPlayerPosition(cid).y+0, z=getPlayerPosition(cid).z+0}
      doSendMagicEffect(pos, 100) -- 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

 

Resolvido por ikaroangelo21

Ir para solução
  • Respostas 6
  • Visualizações 528
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • ikaroangelo21
    ikaroangelo21

    local items = { {itemId = 12377, count = 1, chance = 30}, {itemId = 11987, count = 1, chance = 20}, {itemId = 12338, count = 1, chance = 20}, {itemId = 12032, count = 1, chance = 20}, {itemId = 12031,

  • ikaroangelo21
    ikaroangelo21

    esqueci isso de inicio, atualizei o código, com a função, faça o teste @Kitsune Shiro   local items = { {itemId = 12377, count = 1, chance = 30}, {itemId = 11987, count = 1, chance = 20}, {it

Postado
local items = {
  {itemId = 12337, count = 1, chance = 30}, -- naruto and gamabunta
  {itemId = 11987, count = 1, chance = 20}, -- naruto road to ninja
  {itemId = 12338, count = 1, chance = 20},
  {itemId = 12032, count = 1, chance = 20},
  {itemId = 12031, count = 1, chance = 20},   
  {itemId = 12030, count = 1, chance = 20},
  {itemId = 12547, count = 1, chance = 10},
  {itemId = 15685, count = 1, chance = 1},     
}
local broadcastitems = {12337, 11987, 12338, 12032, 12031, 12030, 12547, 15685}

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, 11753, 1)
      local pos = {x=getPlayerPosition(cid).x+0, y=getPlayerPosition(cid).y+0, z=getPlayerPosition(cid).z+0}
      doSendMagicEffect(pos, 100) -- 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==broadcastitems then doBroadcastMessage(getPlayerName(cid).." acabou de ganhar: "..items.count.." "..items.itemId.." (Raro) na presente box.", 19) end
      end
      break
    end
  end
  return true
  end

 

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

Postado
local items = {
{itemId = 12377, count = 1, chance = 30},
{itemId = 11987, count = 1, chance = 20},
{itemId = 12338, count = 1, chance = 20},
{itemId = 12032, count = 1, chance = 20},
{itemId = 12031, count = 1, chance = 20},
{itemId = 12030, count = 1, chance = 20},
{itemId = 12547, count = 1, chance = 10},
{itemId = 15685, count = 1, chance = 1},
}

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

local config = {
	pos = getCreaturePosition(cid),
	exhaustionSeconds = 3600,
	storageUse = 44231,

}

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, 1)
					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

Atualizado

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

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

Informação Importante

Confirmação de Termo