Ir para conteúdo

Alguem pode fazer esse script tbm teleportar o player ao usalo?

Featured Replies

Postado

local items = {
  {itemId = 2160, count = 10, chance = 90}, -- ITEM, QUANTIDADE, CHANCE

}
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


  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, 1*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, 1*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
return doRemoveItem(item.uid, 1)
      end
      break
    end
  end
  return true
end

Postado
Spoiler

local newpos = {x=1,y=1,z=1} -- posição para onde será teleportado

local items = {
  {itemId = 2160, count = 10, chance = 90}, -- ITEM, QUANTIDADE, CHANCE
}
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

  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, 1*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)
      doTeleportThing(cid, newpos)
      doSendMagicEffect(newpos, CONST_ME_TELEPORT)
      exhaustion.set(cid, config.storageUse, config.exhaustionSeconds)
      local iInfo = getItemInfo(itemId)
      addEvent(doPlayerSendTextMessage, 1*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
        return doRemoveItem(item.uid, 1)
      end
      break
    end
  end
  return true
end

 

 

Contato:

 

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