Lava Titan
Developer
Hello, I wrote this, I thought it was working fine until I noticed it's executing all config at same time instead of execute only the part related to the monster killed...
Can some1 have a look and tell me what I got wrong?
(If possible post an example how to correct please)
Thanks in advance!
Can some1 have a look and tell me what I got wrong?
(If possible post an example how to correct please)
Code:
--[[ Config]]--
local monsters = {
[1] = {
name = "Demon",
tpFrom = {x = 4639, y = 4973, z = 4},
tpTo = {x = 4647, y = 4991, z = 4},
msg = "Test Msg 1",
msgPos = {x = 4638, y = 4968, z = 4},
},
[2] = {
name = "Rotworm",
tpFrom = {x = 4639, y = 4973, z = 4},
tpTo = {x = 4647, y = 4991, z = 4},
msg = "Test Msg 2",
msgPos = {x = 4638, y = 4968, z = 4},
}
}
--<< Script Start >>--
function onKill(creature, target)
if target:isPlayer(target) then
print("Error..")
return true
end
for i = 1, #monsters do
local spectators = getCustomSpectators(monsters[i].tpFrom, false, true, false, false, 10, 10, 10, 10)
for k = 1, #spectators do
local function teleportSpectators(pos) -- monsters[i].tpTo
spectators[k]:teleportTo(pos)
return true
end
local function spectatorsSpeak(msg) -- monsters[i].tpTo
spectators[k]:say(msg, TALKTYPE_MONSTER_SAY, false, spectators[k], monsters[i].msgPos)
return true
end
local function spectatorsCountdown(cid)
addEvent(spectatorsSpeak, 1000, "10")
addEvent(spectatorsSpeak, 2000, "9")
addEvent(spectatorsSpeak, 3000, "8")
addEvent(spectatorsSpeak, 4000, "7")
addEvent(spectatorsSpeak, 5000, "6")
addEvent(spectatorsSpeak, 6000, "5")
addEvent(spectatorsSpeak, 7000, "4")
addEvent(spectatorsSpeak, 8000, "3")
addEvent(spectatorsSpeak, 9000, "2")
addEvent(spectatorsSpeak, 10000, "1")
return true
end
if target:isMonster(target) then
if target:getName() == monsters[i].name then
spectators[k]:say(monsters[i].msg, TALKTYPE_MONSTER_SAY, false, spectators[k], monsters[i].msgPos)
addEvent(spectatorsCountdown, 10000, cid)
addEvent(teleportSpectators, 20000, monsters[i].tpTo)
end
end
end
end
return true
end
Thanks in advance!