Ir para conteúdo

Featured Replies

Postado

Salve galera, eu uso TFS 0.4 protocolo 8.60 e estou com um script que muda a rate do loot, que no caso usando um ring. No entanto, as vezes, acho que depende do monstro, apresenta esse erro na distro:

1481331013_ERROLOOTRING.thumb.jpg.88ce58d7005b1cdb1f1c10377e6e88a6.jpg

 

Alguém tem alguma solução pra isso??

 

  Citar

 

 

 

local t = {
item = 2127,
slot = CONST_SLOT_RING,
newRate = 5
}

local rate = getConfigInfo('rateLoot')

function getContentDescription(uid, comma)
local ret, i, containers = '', 0, {}
while i < getContainerSize(uid) do
local v, s = getContainerItem(uid, i), ''
local k = getItemInfo(v.itemid)
if k.name ~= '' then
if v.type > 1 and k.stackable and k.showCount then
s = v.type .. ' ' .. getItemInfo(v.itemid).plural
else
local article = k.article
s = (article == '' and '' or article .. ' ') .. k.name
end
ret = ret .. (i == 0 and not comma and '' or ', ') .. s
if isContainer(v.uid) and getContainerSize(v.uid) > 0 then
table.insert(containers, v.uid)
end
else
ret = ret .. (i == 0 and not comma and '' or ', ') .. 'an item of type ' .. v.itemid .. ', please report it to gamemaster'
end
i = i + 1
end
for i = 1, #containers do
ret = ret .. getContentDescription(containers[i], true)
end
return ret
end

local function send(cid, pos, corpseid, monster, party)
local corpse = getTileItemById(pos, corpseid).uid
local ret = isContainer(corpse) and getContentDescription(corpse)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'))
if party then
for _, pid in ipairs(getPartyMembers(party)) do
doPlayerSendChannelMessage(pid, '', 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'), TALKTYPE_CHANNEL_W, CHANNEL_PARTY)
end
end
end

local function createLoot(i, ext)
local item = type(i.id) == 'table' and i.id[math.random(#i.id)] or i.id
local random = math.ceil(math.random(100000) / (ext and t.newRate or rate))
local tmpItem

if random < i.chance then
tmpItem = doCreateItemEx(item, getItemInfo(item).stackable and random % i.count + 1 or 1)
end

if not tmpItem then
return
end

if i.subType ~= -1 then
doItemSetAttribute(tmpItem, 'subType', i.subType)
end

if i.actionId ~= -1 then
doItemSetAttribute(tmpItem, 'aid', i.actionId)
end

if i.uniqueId ~= -1 then
doItemSetAttribute(tmpItem, 'uid', i.uniqueId)
end

if i.text ~= '' then
doItemSetAttribute(tmpItem, 'text', i.text)
end

return tmpItem
end

local function createChildLoot(parent, i, ext)
if #i == 0 then
return true
end

local size, cap = 0, getContainerCap(parent)
for k = 1, #i do
if size == cap then
break
end
local tmp = createLoot(i[k], ext)
if tmp then
if isContainer(tmp) then
if createChildLoot(tmp, i[k].child, ext) then
doAddContainerItemEx(parent, tmp)
size = size + 1
else
doRemoveItem(tmp)
end
else
doAddContainerItemEx(parent, tmp)
size = size + 1
end
end
end

return size > 0
end

local function dropLoot(pos, v, ext)
local corpse = getTileItemById(pos, v.lookCorpse).uid
if isContainer(corpse) then
for i = 1, getContainerSize(corpse) do
doRemoveItem(getContainerItem(corpse, 0).uid)
end
local size, cap = 0, getContainerCap(corpse)
for i = 1, #v.loot do
if size == cap then
break
end
local tmp = createLoot(v.loot[i], ext)
if tmp then
if isContainer(tmp) then
if createChildLoot(tmp, v.loot[i].child, ext) then
doAddContainerItemEx(corpse, tmp)
size = size + 1
else
doRemoveItem(tmp)
end
else
doAddContainerItemEx(corpse, tmp)
size = size + 1
end
end
end
end
end

function onKill(cid, target, lastHit)
if lastHit and isMonster(target) then
local v = getMonsterInfo(getCreatureName(target))
if v.lookCorpse > 0 then
local master = getCreatureMaster(target)
if not master or master == target then
addEvent(dropLoot, 0, getThingPos(target), v, getPlayerSlotItem(cid, t.slot).itemid == t.item)
end
addEvent(send, 100, cid, getThingPos(target), v.lookCorpse, v.description, getPlayerParty(cid))
end
end
return true
end 

 

 

 

  • Respostas 6
  • Visualizações 783
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • MatteusDeli
    MatteusDeli

    @stauro Boa noite, tente adicionar essa tag no final antes de fechar o </monster> de qualquer arquivo xml da pasta monster (por exemplo amazon.xml) para ver se vai acontecer esse erro.  

Posted Images

Postado

@stauro Boa noite, tente adicionar essa tag no final antes de fechar o </monster> de qualquer arquivo xml da pasta monster (por exemplo amazon.xml) para ver se vai acontecer esse erro.

 

No NomeDoEventoRegistrado você coloca o nome que você registrou no login.lua ou no creaturescripts.xml que faz executar esse script.

 

<script>
	<event name="NomeDoEventoRegistrado"/>
</script>

 

Postado
  • Autor
  Em 17/06/2021 em 02:26, MatteusDeli disse:

@stauro Boa noite, tente adicionar essa tag no final antes de fechar o </monster> de qualquer arquivo xml da pasta monster (por exemplo amazon.xml) para ver se vai acontecer esse erro.

 

No NomeDoEventoRegistrado você coloca o nome que você registrou no login.lua ou no creaturescripts.xml que faz executar esse script.

 


<script>
	<event name="NomeDoEventoRegistrado"/>
</script>

 

Vou testar essa tag </monster> e essa do login.lua já está como vc falou. Vou testar e qualquer coisa eu volto aqui. Muito obrigado, amigo!

Postado
  • Autor
  Em 17/06/2021 em 02:26, MatteusDeli disse:

@stauro Boa noite, tente adicionar essa tag no final antes de fechar o </monster> de qualquer arquivo xml da pasta monster (por exemplo amazon.xml) para ver se vai acontecer esse erro.

 

No NomeDoEventoRegistrado você coloca o nome que você registrou no login.lua ou no creaturescripts.xml que faz executar esse script.

 


<script>
	<event name="NomeDoEventoRegistrado"/>
</script>

 

Ainda está dando erro. Esse é um dos monstros que constatei quando mata usando o ring aparece o erro na distro

 

<?xml version="1.0" encoding="UTF-8"?>
<monster name="Dark Apprentice" nameDescription="a dark apprentice" race="blood" experience="100" speed="220" manacost="0">
    <health now="225" max="225"/>
    <look type="133" head="78" body="38" legs="95" feet="115" addons="1" corpse="3058"/>
    <targetchange interval="5000" chance="30"/>
    <strategy attack="100" defense="0"/>
    <flags>
        <flag summonable="0"/>
        <flag attackable="1"/>
        <flag hostile="1"/>
        <flag illusionable="0"/>
        <flag convinceable="0"/>
        <flag pushable="0"/>
        <flag canpushitems="1"/>
        <flag canpushcreatures="1"/>
        <flag targetdistance="4"/>
        <flag staticattack="90"/>
        <flag runonhealth="80"/>
    </flags>
    <attacks>
        <attack name="melee" interval="2000" skill="30" attack="30"/>
        <attack name="fire" interval="2000" chance="7" range="7" radius="1" target="1" min="-2" max="-26">
            <attribute key="shootEffect" value="fire"/>
            <attribute key="areaEffect" value="fireattack"/>
        </attack>    
        <attack name="energy" interval="2000" chance="10" range="7" target="1" min="-10" max="-20">
            <attribute key="shootEffect" value="energyball"/>
            <attribute key="areaEffect" value="energy"/>
        </attack>    
        <attack name="physical" interval="2000" chance="8" range="7" target="1" min="-0" max="-24">
            <attribute key="shootEffect" value="smallstone"/>
        </attack>
        <attack name="outfit" interval="2000" chance="10" monster="cyclops" duration="5000"/>
    </attacks>
    <defenses armor="15" defense="20">
    <defense name="outfit" interval="2000" chance="10" monster="green frog" duration="5000"/>    
        <defense name="healing" interval="2000" chance="12" min="50" max="75">
            <attribute key="areaEffect" value="blueshimmer"/>
        </defense>
        <defense name="invisible" interval="2000" chance="6" duration="5000">
            <attribute key="areaEffect" value="redshimmer"/>
        </defense>
    </defenses>
    <elements>
        <element deathPercent="-5"/>
    </elements>
    <immunities>
        <immunity invisible="1"/>
    </immunities>
    <voices interval="5000" chance="10">
        <voice sentence="Outch!"/>
        <voice sentence="Oops, I did it again."/>
        <voice sentence="From the spirits that I called Sir, deliver me!"/>
        <voice sentence="I must dispose of my masters enemies!"/>
    </voices>
    <loot>
    <item id="7618" chance="2775" /><!-- health potion -->
    <item id="13226" chance="800" /><!-- Reins -->
    <item id="2148" countmax="45" chance="39500" /><!-- gold coin -->
    <item id="2260" countmax="3" chance="6100" /><!-- blank rune -->
    <item id="1987" chance="100000"><!-- bag -->
        <inside>
            <item id="7620" chance="3050" /><!-- mana potion -->
            <item id="2191" chance="2300" /><!-- wand of dragonbreath -->
            <item id="5934" chance="7900" /><!-- dead frog -->
        </inside>
    </item>
</loot>
</monster>

Postado

@stauro Boa tarde, tente assim

 

Não precisa adicionar a tag script nos monsters, aparentemente o que está dando esse erro é que o alguns monstros nao dropam a bag.

 

local t = {
  item = 2127,
  slot = CONST_SLOT_RING,
  newRate = 5
  }
  
  local rate = getConfigInfo('rateLoot')
  
  function getContentDescription(uid, comma)
  local ret, i, containers = '', 0, {}
  while i < getContainerSize(uid) do
  local v, s = getContainerItem(uid, i), ''
  local k = getItemInfo(v.itemid)
  if k.name ~= '' then
  if v.type > 1 and k.stackable and k.showCount then
  s = v.type .. ' ' .. getItemInfo(v.itemid).plural
  else
  local article = k.article
  s = (article == '' and '' or article .. ' ') .. k.name
  end
  ret = ret .. (i == 0 and not comma and '' or ', ') .. s
  if isContainer(v.uid) and getContainerSize(v.uid) > 0 then
  table.insert(containers, v.uid)
  end
  else
  ret = ret .. (i == 0 and not comma and '' or ', ') .. 'an item of type ' .. v.itemid .. ', please report it to gamemaster'
  end
  i = i + 1
  end
  for i = 1, #containers do
  ret = ret .. getContentDescription(containers[i], true)
  end
  return ret
  end
  
  local function send(cid, pos, corpseid, monster, party)
  local corpse = getTileItemById(pos, corpseid).uid
  local ret = isContainer(corpse) and getContentDescription(corpse)
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'))
  if party then
  for _, pid in ipairs(getPartyMembers(party)) do
  doPlayerSendChannelMessage(pid, '', 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'), TALKTYPE_CHANNEL_W, CHANNEL_PARTY)
  end
  end
  end
  
  local function createLoot(i, ext)
  local item = type(i.id) == 'table' and i.id[math.random(#i.id)] or i.id
  local random = math.ceil(math.random(100000) / (ext and t.newRate or rate))
  local tmpItem
  
  if random < i.chance then
  tmpItem = doCreateItemEx(item, getItemInfo(item).stackable and random % i.count + 1 or 1)
  end
  
  if not tmpItem then
  return
  end
  
  if i.subType ~= -1 then
  doItemSetAttribute(tmpItem, 'subType', i.subType)
  end
  
  if i.actionId ~= -1 then
  doItemSetAttribute(tmpItem, 'aid', i.actionId)
  end
  
  if i.uniqueId ~= -1 then
  doItemSetAttribute(tmpItem, 'uid', i.uniqueId)
  end
  
  if i.text ~= '' then
  doItemSetAttribute(tmpItem, 'text', i.text)
  end
  
  return tmpItem
  end
  
  local function createChildLoot(parent, i, ext)
  if #i == 0 then
    return true
  end
  
  local size, cap = 0, getContainerCap(parent)
  for k = 1, #i do
  if size == cap then
  break
  end
  local tmp = createLoot(i[k], ext)
  if tmp then
  if isContainer(tmp) then
    if i[k].child == nil then
      break
    end
  if createChildLoot(tmp, i[k].child, ext) then
  doAddContainerItemEx(parent, tmp)
  size = size + 1
  else
  doRemoveItem(tmp)
  end
  else
  doAddContainerItemEx(parent, tmp)
  size = size + 1
  end
  end
  end
  
  return size > 0
  end
  
  local function dropLoot(pos, v, ext)
  local corpse = getTileItemById(pos, v.lookCorpse).uid
  if isContainer(corpse) then
    for i = 1, getContainerSize(corpse) do
      doRemoveItem(getContainerItem(corpse, 0).uid)
    end
    local size, cap = 0, getContainerCap(corpse)
      for i = 1, #v.loot do
        if size == cap then
          break
        end
    local tmp = createLoot(v.loot[i], ext)
  if tmp then
  if isContainer(tmp) then
  if createChildLoot(tmp, v.loot[i].child, ext) then
  doAddContainerItemEx(corpse, tmp)
  size = size + 1
  else
  doRemoveItem(tmp)
  end
  else
  doAddContainerItemEx(corpse, tmp)
  size = size + 1
  end
  end
  end
  end
  end
  
  function onKill(cid, target, lastHit)
  if lastHit and isMonster(target) then
  local v = getMonsterInfo(getCreatureName(target))
  if v.lookCorpse > 0 then
  local master = getCreatureMaster(target)
  if not master or master == target then
  addEvent(dropLoot, 0, getThingPos(target), v, getPlayerSlotItem(cid, t.slot).itemid == t.item)
  end
  addEvent(send, 100, cid, getThingPos(target), v.lookCorpse, v.description, getPlayerParty(cid))
  end
  end
  return true
  end

 

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.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo