Ir para conteúdo
  • 0

Boss Spawn Apos Matar X Quantidade de Creature! (Ajuda)


ZeusMnc

Pergunta

Hello Xtibia!  TFS 0.4 8.60


Estou com um problema no script e gostaria de uma ajuda! 

Ele funciona da Seguinte forma apos matar x Creatures Spawn Boss na Regiao! 

Porem nao esta contabilizando as creatures no chat!
Acredito que tenho que alterar algo na

function para identificar o player e soltar o aviso para ele! (Pelo oque entendi o script n consegue verificar quem e o player que esta matando a creature!


Error Distro:

Spoiler

[11:34:38.369] [Error - CreatureScript Interface]
[11:34:38.371] data/creaturescripts/scripts/BossCreature.lua:onDeath
[11:34:38.372] Description:
[11:34:38.372] (luaGetCreatureName) Creature not found

[11:34:38.373] [Error - CreatureScript Interface]
[11:34:38.373] data/creaturescripts/scripts/BossCreature.lua:onDeath
[11:34:38.374] Description:
[11:34:38.374] data/creaturescripts/scripts/BossCreature.lua:39: attempt to concatenate a boolean value
[11:34:38.374] stack traceback:
[11:34:38.375]  data/creaturescripts/scripts/BossCreature.lua:39: in function <data/creaturescripts/scripts/BossCreature.lua:16>

 

Script : BossCreature.Lua (CreatureScript)
 

Spoiler

function doCreateMonsterWalkableAreaPosition(name, from, to)
   local pos = {x=math.random(from.x, to.x), y=math.random(from.y, to.y), z=math.random(from.z, to.z)}
   if isWalkable(pos, false, false, false) then
      doSummonCreature(name, pos)
   else
      doCreateMonsterWalkableAreaPosition(name, from, to)
   end
end

local t = {
   [{"Dragon", "Dragon lord"}] = {storage = 741320, amount = 10, boss = "Boss Dragon", from = {x = 80, y = 187, z = 8}, to = {x = 85, y = 191, z = 8}},
   [{"Black Dragon", " Black Dragon lord"}] = {storage = 741321, amount = 10, boss = "Boss Black Dragon", from = {x = 800, y = 1817, z = 8}, to = {x = 851, y = 1911, z = 8}},
}


function onDeath(cid, corpse, deathList)
   local killer = deathList[1]
   if not isMonster(cid) or not isPlayer(killer) then
      return true
   end
   for v , r in pairs(t) do
      if isInArray(v, getCreatureName(cid)) then
         local contador = getGlobalStorageValue(r.storage) <= 0 and 0 or getGlobalStorageValue(r.storage)
         if contador >= r.amount then
            for x = r.from.x - 1, r.to.x + 1 do
               for y = r.from.y - 1, r.to.y + 1 do
                  local pos = {x=x, y=y, z=r.from.z}
                  local m = getTopCreature(pos).uid
                  if m ~= 0 and isMonster(m) then
                     doRemoveCreature(m)
                  end
               end
            end
            doCreateMonsterWalkableAreaPosition(r.boss, r.from, r.to)
            setGlobalStorageValue(r.storage, 0)
            doBroadcastMessage("O monstro ".. r.boss .." nasceu!", 20)
         else
            setGlobalStorageValue(r.storage, contador + 1)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Boss Spawning: '..(getGlobalStorageValue(r.storage)+1)..' of '..r.amount..' '..getCreatureName(target)..'s killed to spawn boss.') 
         end
      end
   end
   return true
end

Creature Script xml
    <event type="Death" name="BossSpawn" event="script" value="BossCreature.lua"/>

Login.lua
registerCreatureEvent(cid, "BossSpawn")

 

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

Fiz algumas alterações, veja se isso resolve o problema

 

BossCreature.lua:

 

function doCreateMonsterWalkableAreaPosition(name, from, to)
   local pos = {x=math.random(from.x, to.x), y=math.random(from.y, to.y), z=math.random(from.z, to.z)}

   if isWalkable(pos, false, false, false) then
      doSummonCreature(name, pos)
   else
      doCreateMonsterWalkableAreaPosition(name, from, to)
   end
end

local t = {
   [{"Dragon", "Dragon lord"}] = {storage = 741320, amount = 10, boss = "Boss Dragon", from = {x = 80, y = 187, z = 8}, to = {x = 85, y = 191, z = 8}},
   [{"Black Dragon", " Black Dragon lord"}] = {storage = 741321, amount = 10, boss = "Boss Black Dragon", from = {x = 800, y = 1817, z = 8}, to = {x = 851, y = 1911, z = 8}},
}


function onKill(cid, target, lastHit)
   if not isMonster(target) or not isPlayer(cid) then
      return true
   end
   for v, r in pairs(t) do
      if isInArray(v, getCreatureName(target)) then
         local contador = getGlobalStorageValue(r.storage) <= 0 and 0 or getGlobalStorageValue(r.storage)
         if contador >= r.amount then
            for x = r.from.x - 1, r.to.x + 1 do
               for y = r.from.y - 1, r.to.y + 1 do
                  local pos = {x=x, y=y, z=r.from.z}
                  local m = getTopCreature(pos).uid
                  if m ~= 0 and isMonster(m) then
                     doRemoveCreature(m)
                  end
               end
            end
            doCreateMonsterWalkableAreaPosition(r.boss, r.from, r.to)
            setGlobalStorageValue(r.storage, 0)
            doBroadcastMessage("O monstro ".. r.boss .." nasceu!", 20)
         else
            setGlobalStorageValue(r.storage, contador + 1)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Boss Spawning: "..(getGlobalStorageValue(r.storage)).." of "..r.amount.." "..getCreatureName(target).."'s killed to spawn boss.") 
         end
      end
   end
   return true
end

 

 

em creaturescripts.xml altere a tag para:

 

<event type="kill" name="BossSpawn" event="script" value="BossCreature.lua"/> 

 

Link para o comentário
Compartilhar em outros sites

  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...