Ir para conteúdo
  • 0

creaturescript onDeath()


othereality

Pergunta

olá, eu estava querendo fazer um creaturescript que ao matar o monstro aparece um teleport embaixo dele por 10 e depois ele sumisse:
eu peguei uns arquivos e editei um pouco e ficou assim:

function removeTp(tp)
local tpId = 1387
local tps = {
        ["Pesmak"] = {pos = getCreaturePosition(cid)},
}


        local t = getTileItemById(tp.pos, tpId)
        if t then
                doRemoveItem(t.uid, 1)
                doSendMagicEffect(tp.pos, CONST_ME_POFF)
        end
end


function onDeath(cid)
local tpId = 1387
local tps = {
        ["Pesmak"] = {pos = getCreaturePosition(cid), toPos = {x=621, y=461, z=6}, time = 10},
}


        local tp = tps[getCreatureName(cid)]
        if tp then
                doCreateTeleport(tpId, tp.toPos, tp.pos)
                doCreatureSay(cid, "O teleport irá sumir em "..tp.time.." segundos.", TALKTYPE_ORANGE_1)
                addEvent(removeTp, tp.time*1000, tp)
        end
        return TRUE
end

O script funciona perfeitamente mas sempre que o teleport some dá o seguinte erro no console:

[19/03/2014 11:58:11] [Error - CreatureScript Interface] 
[19/03/2014 11:58:11] In a timer event called from: 
[19/03/2014 11:58:11] data/creaturescripts/scripts/bosses.lua:onDeath
[19/03/2014 11:58:11] Description: 
[19/03/2014 11:58:11] (luaGetThingPosition) Thing not found

pelo que entendi isso acontece pq ele não consegue encontra a posição do monstro depois que ele já morreu.
mas o teleport some direitinho depois dos 10 segundos.

se alguém souber me ajudar agradeço.

 

Link para o comentário
https://xtibia.com/forum/topic/230350-creaturescript-ondeath/
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

local config = {
message = "Parabéns. O Teleport fecha em 10 segundos",
timeToRemove = 10, -- tempo em segundos.
teleportId = 1387, -- id do teleport
bosses = {
["The Killer"] = { x = 144, y = 49, z = 7 }, -- nome do monster
                                         -- e posição para onde é teleportado.
}
}

local function removal(position)
doRemoveThing(getTileItemById(position, config.teleportId).uid, 1)
return TRUE
end

function onDeath(cid, corpse, killer)
registerCreatureEvent(cid, "teleportmonster")
local position = getCreaturePosition(cid)

for name, pos in pairs(config.bosses) do
if name == getCreatureName(cid) then
teleport = doCreateTeleport(config.teleportId, pos, position)
doCreatureSay(cid, config.message, TALKTYPE_ORANGE_1)
addEvent(removal, config.timeToRemove * 1000, position)
doSendMagicEffect(position,10)
end
end
return TRUE
end

coloca isso no monster.xml :

<script>
<event name="nome do Evento"/>
</script>
Link para o comentário
https://xtibia.com/forum/topic/230350-creaturescript-ondeath/#findComment-1625673
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

×
×
  • Criar Novo...