Tbol
Well-Known Member
- Joined
- Apr 7, 2019
- Messages
- 526
- Reaction score
- 54
So have issue with this code especially when multiple creatures get involved it doesnt create teleport. I will comment the parts that works and the part that doesnt work.
You see this part i commented that doesnt work so i tested it on localhost and with admin i killed those creatures so it created the portal, but then i tried go a hard way being regular player i noticed that it didnt created the portal maybe because it took like a lot of time to kill all monsters so code for some reason didnt created it. Basically its like really unstable code i would say.
Lua:
local config = {
{mobs = {"Test 1", "Test 2", "Super Test 1", "Super Test 2", "Elite Test 1", "Elite Test 2"}, pos = Position(1039, 1122, 8), destination = Position(1138, 1191, 8), duration = 15}, -- DOESNT WORK
{mobs = {"Test10 (1)"}, pos = Position(1027, 1165, 7), destination = Position(1047, 1160, 7), duration = 10}, -- WORKS PERFECT
{mobs = {"Test10 (2)"}, pos = Position(1047, 1154, 7), destination = Position(1039, 1173, 7), duration = 10}, -- WORKS PERFECT
{mobs = {"Test11 (1)"}, pos = Position(1067, 1174, 7), destination = Position(1015, 1187, 7), duration = 10}, -- WORKS PERFECT
{mobs = {"Test11 (2)"}, pos = Position(1011, 1209, 7), destination = Position(1041, 1186, 7), duration = 10}, -- WORKS PERFECT
{mobs = {"Test12 (1)"}, pos = Position(1038, 1210, 7), destination = Position(1063, 1188, 7), duration = 10}, -- WORKS PERFECT
{mobs = {"Test12 (2)"}, pos = Position(1119, 1193, 7), destination = Position(1039, 1240, 8), duration = 10}, -- WORKS PERFECT
}
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified)
local name = creature:getName()
for _, mob_array in pairs(config) do
if isInArray(mob_array.mobs, name) then
for _, mob in pairs(mob_array.mobs) do
local mob_temp = Creature(mob)
if mob_temp and mob_temp.uid ~= creature.uid then
return true
end
end
local portal = doCreateTeleport(1387, mob_array.destination, mob_array.pos)
if portal then
if killer then
local string = "You have " .. mob_array.duration .. " " .. (mob_array.duration > 1 and 'minutes' or 'minute') .. " to enter the portal."
killer:say(string, TALKTYPE_MONSTER_SAY)
end
addEvent(function(pos)
local portal = Tile(pos):getItemById(1387)
if portal then
portal:remove()
pos:sendMagicEffect(CONST_ME_POFF)
end
end, mob_array.duration * 60 * 1000, mob_array.pos)
end
break
end
end
return true
end
You see this part i commented that doesnt work so i tested it on localhost and with admin i killed those creatures so it created the portal, but then i tried go a hard way being regular player i noticed that it didnt created the portal maybe because it took like a lot of time to kill all monsters so code for some reason didnt created it. Basically its like really unstable code i would say.