Postado Setembro 28, 2017 7 anos Autor 3 horas atrás, Dwarfer disse: Você deve ter testado em um uniqueid que não existe na tabela. O seu script inicial apresentava esse problema. FUNCIONOU! Perfeito, 101% '-' Muito obrigadoo Dwarfer. Ficou Perfectt!
Postado Setembro 28, 2017 7 anos Autor Em 26/09/2017 em 15:37, Dwarfer disse: Adicione novas kickpos (posição para qual o player será teleportado) para os outros bosses, só fiz a primeira como exemplo e comentei o restante. Mostrar conteúdo oculto local timetokick = {5, "min"} -- tempo para ser kikado da sala do boss local teleports = { -- Tile UID = {storage of task, amount of monsters, monsters to spawn} [14001] = {monsters = {"Leviathan"}, telePos = {x = 31914, y = 31071, z = 10}, spawnPos = {x = 31905, y = 31071, z = 10}, from = {x = 31900, y = 31064, z = 10}, to = {x = 31918, y = 31081, z = 10}, kickpos = {x = 1, y = 1, z = 1}}, --[[ [14002] = {monsters = {"The Noxious Spawn"}, telePos = {x = 32842, y = 32668, z = 11}, spawnPos = {x = 32842, y = 32673, z = 11}, from = {x = 32836, y = 32665, z = 11}, to = {x = 32849, y = 32677, z = 11}}, [14003] = {monsters = {"Necropharus"}, telePos = {x = 33028, y = 32427, z = 12}, spawnPos = {x = 33028, y = 32421, z = 12}, from = {x = 33020, y = 32415, z = 12}, to = {x = 33035, y = 32430, z = 12}}, [14004] = {monsters = {"The Horned Fox"}, telePos = {x = 32458, y = 31993, z = 9}, spawnPos = {x = 32458, y = 32004, z = 9}, from = {x = 32453, y = 31992, z = 9}, to = {x = 32464, y = 32008, z = 9}}, [14005] = {monsters = {"Lethal Lissy", "Ron The Ripper", "Deadeye Devious", "Brutus Bloodbeard"}, telePos = {x = 31975, y = 32896, z = 0}, spawnPos = {x = 31982, y = 32896, z = 0}, from = {x = 31972, y = 32890, z = 0}, to = {x = 31988, y = 32904, z = 0}}, [14007] = {monsters = {"The Snapper"}, telePos = {x = 244, y = 647, z = 8}, spawnPos = {x = 236, y = 643, z = 8}, from = {x = 232, y = 640, z = 8}, to = {x = 245, y = 651, z = 8}}, [14008] = {monsters = {"Hide"}, telePos = {x = 32815, y = 32704, z = 8}, spawnPos = {x = 32816, y = 32708, z = 8}, from = {x = 32810, y = 32701, z = 8}, to = {x = 32824, y = 32713, z = 8}}, [14012] = {monsters = {"Shardhead"}, telePos = {x = 32102, y = 31125, z = 2}, spawnPos = {x = 32101, y = 31130, z = 2}, from = {x = 32095, y = 31122, z = 2}, to = {x = 32108, y = 31136, z = 2}}, [14019] = {monsters = {"Esmeralda"}, telePos = {x = 32759, y = 31253, z = 9}, spawnPos = {x = 32759, y = 31256, z = 9}, from = {x = 32755, y = 31250, z = 9}, to = {x = 32764, y = 31259, z = 9}}, [14020] = {monsters = {"The Old Widow"}, telePos = {x = 32804, y = 32280, z = 8}, spawnPos = {x = 32800, y = 32280, z = 8}, from = {x = 32794, y = 32273, z = 8}, to = {x = 32807, y = 32288, z = 8}}, [14021] = {monsters = {"The Many"}, telePos = {x = 32921, y = 32894, z = 8}, spawnPos = {x = 32921, y = 32899, z = 8}, from = {x = 32915, y = 32891, z = 8}, to = {x = 32927, y = 32904, z = 8}}, [14506] = {monsters = {"Demodras"}, telePos = {x = 32748, y = 32287, z = 10}, spawnPos = {x = 32745, y = 32292, z = 10}, from = {x = 32738, y = 32283, z = 10}, to = {x = 32757, y = 32300, z = 10}}, [14505] = {monsters = {"Tiquandas Revenge"}, telePos = {x = 32888, y = 32580, z = 4}, spawnPos = {x = 32883, y = 32580, z = 4}, from = {x = 32881, y = 32578, z = 4}, to = {x = 32892, y = 32588, z = 4}}, [14022] = {monsters = {"Stonecracker"}, telePos = {x = 33259, y = 31695, z = 15}, spawnPos = {x = 33257, y = 31702, z = 15}, from = {x = 33252, y = 31691, z = 15}, to = {x = 33266, y = 31708, z = 15}}, ]]-- } local function getCreaturesInArea(fromPos, toPos, creatureType) local creatures = {} for x = fromPos.x, toPos.x do for y = fromPos.y, toPos.y do for z = fromPos.z, toPos.z do local creature = getTopCreature({x = x, y = y, z = z}).uid local cType creatureType:lower() if (cType == "players" and isPlayer(creature)) then table.insert(creatures, creature) elseif (cType == "monsters" and isMonster(creature)) then table.insert(creatures, creature) elseif (cType == "npcs" and isNpc(creature)) then table.insert(creatures, creature) elseif (cType == "all") then table.insert(creatures, creature) end end end end return creatures end function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local now = teleports[item.uid] if (#getCreaturesInArea(now.from, now.to, "players") > 0) then doTeleportThing(cid, fromPosition, true) doPlayerSendCancel(cid, "Someone else is in the room.") end if getPlayerStorageValue(cid, item.uid + (item.uid < 14500 and 100 or 0)) == 1 then for _, monster in ipairs(getCreaturesInArea(now.from, now.to, "monsters")) do doRemoveCreature(monster) end setPlayerStorageValue(cid, item.uid + (item.uid < 14500 and 100 or 0), 2) doTeleportThing(cid, now.telePos) doSendMagicEffect(now.telePos, CONST_ME_TELEPORT) doSummonCreature(now.monsters[math.random(#now.monsters)], now.spawnPos) doSendMagicEffect(now.spawnPos, CONST_ME_TELEPORT) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You will be kicked from boss room in " .. timetokick[1] .. " "..timetokick[2]..".") addEvent(kickPlayerFromArea, mathtime(timetokick) * 1000, cid, {now.from, now.to, now.kickpos}) return true end doTeleportThing(cid, fromPosition, true) return true end function kickPlayerFromArea(cid, p) if isPlayer(cid) and isInRange(getPlayerPosition(cid), p[1], p[2]) then doTeleportThing(cid, p[3]) doSendMagicEffect(p[3], CONST_ME_TELEPORT) end end function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end @Dwarfer, desculpa te marcar novamente... É que quando tem um player lá dentro da sala do boss, outro player pode entrar normalmente... Era para aparecer a mensagem: doPlayerSendCancel(cid, "Someone else is in the room.")
Postado Setembro 28, 2017 7 anos 2 minutos atrás, iLLarious disse: @Dwarfer, desculpa te marcar novamente... É que quando tem um player lá dentro da sala do boss, outro player pode entrar normalmente... Era para aparecer a mensagem: doPlayerSendCancel(cid, "Someone else is in the room.") Hm.. vê assim: Spoiler local timetokick = {5, "min"} -- tempo para ser kikado da sala do boss local teleports = { -- Tile UID = {storage of task, amount of monsters, monsters to spawn} [14001] = {monsters = {"Leviathan"}, telePos = {x = 31914, y = 31071, z = 10}, spawnPos = {x = 31905, y = 31071, z = 10}, from = {x = 31900, y = 31064, z = 10}, to = {x = 31918, y = 31081, z = 10}, kickpos = {x = 1, y = 1, z = 1}}, --[[ [14002] = {monsters = {"The Noxious Spawn"}, telePos = {x = 32842, y = 32668, z = 11}, spawnPos = {x = 32842, y = 32673, z = 11}, from = {x = 32836, y = 32665, z = 11}, to = {x = 32849, y = 32677, z = 11}}, [14003] = {monsters = {"Necropharus"}, telePos = {x = 33028, y = 32427, z = 12}, spawnPos = {x = 33028, y = 32421, z = 12}, from = {x = 33020, y = 32415, z = 12}, to = {x = 33035, y = 32430, z = 12}}, [14004] = {monsters = {"The Horned Fox"}, telePos = {x = 32458, y = 31993, z = 9}, spawnPos = {x = 32458, y = 32004, z = 9}, from = {x = 32453, y = 31992, z = 9}, to = {x = 32464, y = 32008, z = 9}}, [14005] = {monsters = {"Lethal Lissy", "Ron The Ripper", "Deadeye Devious", "Brutus Bloodbeard"}, telePos = {x = 31975, y = 32896, z = 0}, spawnPos = {x = 31982, y = 32896, z = 0}, from = {x = 31972, y = 32890, z = 0}, to = {x = 31988, y = 32904, z = 0}}, [14007] = {monsters = {"The Snapper"}, telePos = {x = 244, y = 647, z = 8}, spawnPos = {x = 236, y = 643, z = 8}, from = {x = 232, y = 640, z = 8}, to = {x = 245, y = 651, z = 8}}, [14008] = {monsters = {"Hide"}, telePos = {x = 32815, y = 32704, z = 8}, spawnPos = {x = 32816, y = 32708, z = 8}, from = {x = 32810, y = 32701, z = 8}, to = {x = 32824, y = 32713, z = 8}}, [14012] = {monsters = {"Shardhead"}, telePos = {x = 32102, y = 31125, z = 2}, spawnPos = {x = 32101, y = 31130, z = 2}, from = {x = 32095, y = 31122, z = 2}, to = {x = 32108, y = 31136, z = 2}}, [14019] = {monsters = {"Esmeralda"}, telePos = {x = 32759, y = 31253, z = 9}, spawnPos = {x = 32759, y = 31256, z = 9}, from = {x = 32755, y = 31250, z = 9}, to = {x = 32764, y = 31259, z = 9}}, [14020] = {monsters = {"The Old Widow"}, telePos = {x = 32804, y = 32280, z = 8}, spawnPos = {x = 32800, y = 32280, z = 8}, from = {x = 32794, y = 32273, z = 8}, to = {x = 32807, y = 32288, z = 8}}, [14021] = {monsters = {"The Many"}, telePos = {x = 32921, y = 32894, z = 8}, spawnPos = {x = 32921, y = 32899, z = 8}, from = {x = 32915, y = 32891, z = 8}, to = {x = 32927, y = 32904, z = 8}}, [14506] = {monsters = {"Demodras"}, telePos = {x = 32748, y = 32287, z = 10}, spawnPos = {x = 32745, y = 32292, z = 10}, from = {x = 32738, y = 32283, z = 10}, to = {x = 32757, y = 32300, z = 10}}, [14505] = {monsters = {"Tiquandas Revenge"}, telePos = {x = 32888, y = 32580, z = 4}, spawnPos = {x = 32883, y = 32580, z = 4}, from = {x = 32881, y = 32578, z = 4}, to = {x = 32892, y = 32588, z = 4}}, [14022] = {monsters = {"Stonecracker"}, telePos = {x = 33259, y = 31695, z = 15}, spawnPos = {x = 33257, y = 31702, z = 15}, from = {x = 33252, y = 31691, z = 15}, to = {x = 33266, y = 31708, z = 15}}, ]]-- } local function getCreaturesInArea(fromPos, toPos, creatureType) local creatures = {} for x = fromPos.x, toPos.x do for y = fromPos.y, toPos.y do for z = fromPos.z, toPos.z do local creature = getTopCreature({x = x, y = y, z = z}).uid local cType creatureType:lower() if (cType == "players" and isPlayer(creature)) then table.insert(creatures, creature) elseif (cType == "monsters" and isMonster(creature)) then table.insert(creatures, creature) elseif (cType == "npcs" and isNpc(creature)) then table.insert(creatures, creature) elseif (cType == "all") then table.insert(creatures, creature) end end end end return creatures end function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local now = teleports[item.uid] if now then if (#getCreaturesInArea(now.from, now.to, "players") > 0) then doTeleportThing(cid, fromPosition, true) doPlayerSendCancel(cid, "Someone else is in the room.") return true end if getPlayerStorageValue(cid, item.uid + (item.uid < 14500 and 100 or 0)) == 1 then for _, monster in ipairs(getCreaturesInArea(now.from, now.to, "monsters")) do doRemoveCreature(monster) end setPlayerStorageValue(cid, item.uid + (item.uid < 14500 and 100 or 0), 2) doTeleportThing(cid, now.telePos) doSendMagicEffect(now.telePos, CONST_ME_TELEPORT) doSummonCreature(now.monsters[math.random(#now.monsters)], now.spawnPos) doSendMagicEffect(now.spawnPos, CONST_ME_TELEPORT) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You will be kicked from boss room in " .. timetokick[1] .. " "..timetokick[2]..".") addEvent(kickPlayerFromArea, mathtime(timetokick) * 1000, cid, {now.from, now.to, now.kickpos}) return true end doTeleportThing(cid, fromPosition, true) end return true end function kickPlayerFromArea(cid, p) if isPlayer(cid) and isInRange(getPlayerPosition(cid), p[1], p[2]) then doTeleportThing(cid, p[3]) doSendMagicEffect(p[3], CONST_ME_TELEPORT) end end function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end Contato: Email: [email protected] Discord: Dwarfer#2715
Postado Setembro 28, 2017 7 anos Autor 5 minutos atrás, Dwarfer disse: Hm.. vê assim: Ocultar conteúdo local timetokick = {5, "min"} -- tempo para ser kikado da sala do boss local teleports = { -- Tile UID = {storage of task, amount of monsters, monsters to spawn} [14001] = {monsters = {"Leviathan"}, telePos = {x = 31914, y = 31071, z = 10}, spawnPos = {x = 31905, y = 31071, z = 10}, from = {x = 31900, y = 31064, z = 10}, to = {x = 31918, y = 31081, z = 10}, kickpos = {x = 1, y = 1, z = 1}}, --[[ [14002] = {monsters = {"The Noxious Spawn"}, telePos = {x = 32842, y = 32668, z = 11}, spawnPos = {x = 32842, y = 32673, z = 11}, from = {x = 32836, y = 32665, z = 11}, to = {x = 32849, y = 32677, z = 11}}, [14003] = {monsters = {"Necropharus"}, telePos = {x = 33028, y = 32427, z = 12}, spawnPos = {x = 33028, y = 32421, z = 12}, from = {x = 33020, y = 32415, z = 12}, to = {x = 33035, y = 32430, z = 12}}, [14004] = {monsters = {"The Horned Fox"}, telePos = {x = 32458, y = 31993, z = 9}, spawnPos = {x = 32458, y = 32004, z = 9}, from = {x = 32453, y = 31992, z = 9}, to = {x = 32464, y = 32008, z = 9}}, [14005] = {monsters = {"Lethal Lissy", "Ron The Ripper", "Deadeye Devious", "Brutus Bloodbeard"}, telePos = {x = 31975, y = 32896, z = 0}, spawnPos = {x = 31982, y = 32896, z = 0}, from = {x = 31972, y = 32890, z = 0}, to = {x = 31988, y = 32904, z = 0}}, [14007] = {monsters = {"The Snapper"}, telePos = {x = 244, y = 647, z = 8}, spawnPos = {x = 236, y = 643, z = 8}, from = {x = 232, y = 640, z = 8}, to = {x = 245, y = 651, z = 8}}, [14008] = {monsters = {"Hide"}, telePos = {x = 32815, y = 32704, z = 8}, spawnPos = {x = 32816, y = 32708, z = 8}, from = {x = 32810, y = 32701, z = 8}, to = {x = 32824, y = 32713, z = 8}}, [14012] = {monsters = {"Shardhead"}, telePos = {x = 32102, y = 31125, z = 2}, spawnPos = {x = 32101, y = 31130, z = 2}, from = {x = 32095, y = 31122, z = 2}, to = {x = 32108, y = 31136, z = 2}}, [14019] = {monsters = {"Esmeralda"}, telePos = {x = 32759, y = 31253, z = 9}, spawnPos = {x = 32759, y = 31256, z = 9}, from = {x = 32755, y = 31250, z = 9}, to = {x = 32764, y = 31259, z = 9}}, [14020] = {monsters = {"The Old Widow"}, telePos = {x = 32804, y = 32280, z = 8}, spawnPos = {x = 32800, y = 32280, z = 8}, from = {x = 32794, y = 32273, z = 8}, to = {x = 32807, y = 32288, z = 8}}, [14021] = {monsters = {"The Many"}, telePos = {x = 32921, y = 32894, z = 8}, spawnPos = {x = 32921, y = 32899, z = 8}, from = {x = 32915, y = 32891, z = 8}, to = {x = 32927, y = 32904, z = 8}}, [14506] = {monsters = {"Demodras"}, telePos = {x = 32748, y = 32287, z = 10}, spawnPos = {x = 32745, y = 32292, z = 10}, from = {x = 32738, y = 32283, z = 10}, to = {x = 32757, y = 32300, z = 10}}, [14505] = {monsters = {"Tiquandas Revenge"}, telePos = {x = 32888, y = 32580, z = 4}, spawnPos = {x = 32883, y = 32580, z = 4}, from = {x = 32881, y = 32578, z = 4}, to = {x = 32892, y = 32588, z = 4}}, [14022] = {monsters = {"Stonecracker"}, telePos = {x = 33259, y = 31695, z = 15}, spawnPos = {x = 33257, y = 31702, z = 15}, from = {x = 33252, y = 31691, z = 15}, to = {x = 33266, y = 31708, z = 15}}, ]]-- } local function getCreaturesInArea(fromPos, toPos, creatureType) local creatures = {} for x = fromPos.x, toPos.x do for y = fromPos.y, toPos.y do for z = fromPos.z, toPos.z do local creature = getTopCreature({x = x, y = y, z = z}).uid local cType creatureType:lower() if (cType == "players" and isPlayer(creature)) then table.insert(creatures, creature) elseif (cType == "monsters" and isMonster(creature)) then table.insert(creatures, creature) elseif (cType == "npcs" and isNpc(creature)) then table.insert(creatures, creature) elseif (cType == "all") then table.insert(creatures, creature) end end end end return creatures end function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local now = teleports[item.uid] if now then if (#getCreaturesInArea(now.from, now.to, "players") > 0) then doTeleportThing(cid, fromPosition, true) doPlayerSendCancel(cid, "Someone else is in the room.") return true end if getPlayerStorageValue(cid, item.uid + (item.uid < 14500 and 100 or 0)) == 1 then for _, monster in ipairs(getCreaturesInArea(now.from, now.to, "monsters")) do doRemoveCreature(monster) end setPlayerStorageValue(cid, item.uid + (item.uid < 14500 and 100 or 0), 2) doTeleportThing(cid, now.telePos) doSendMagicEffect(now.telePos, CONST_ME_TELEPORT) doSummonCreature(now.monsters[math.random(#now.monsters)], now.spawnPos) doSendMagicEffect(now.spawnPos, CONST_ME_TELEPORT) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You will be kicked from boss room in " .. timetokick[1] .. " "..timetokick[2]..".") addEvent(kickPlayerFromArea, mathtime(timetokick) * 1000, cid, {now.from, now.to, now.kickpos}) return true end doTeleportThing(cid, fromPosition, true) end return true end function kickPlayerFromArea(cid, p) if isPlayer(cid) and isInRange(getPlayerPosition(cid), p[1], p[2]) then doTeleportThing(cid, p[3]) doSendMagicEffect(p[3], CONST_ME_TELEPORT) end end function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end Nada ainda. Ainda consigo entrar com + de 1 player ao mesmo tempo na sala do boss =/
Postado Setembro 28, 2017 7 anos Spoiler local timetokick = {5, "min"} -- tempo para ser kikado da sala do boss local teleports = { -- Tile UID = {storage of task, amount of monsters, monsters to spawn} [14001] = {monsters = {"Leviathan"}, telePos = {x = 31914, y = 31071, z = 10}, spawnPos = {x = 31905, y = 31071, z = 10}, from = {x = 31900, y = 31064, z = 10}, to = {x = 31918, y = 31081, z = 10}, kickpos = {x = 1, y = 1, z = 1}}, --[[ [14002] = {monsters = {"The Noxious Spawn"}, telePos = {x = 32842, y = 32668, z = 11}, spawnPos = {x = 32842, y = 32673, z = 11}, from = {x = 32836, y = 32665, z = 11}, to = {x = 32849, y = 32677, z = 11}}, [14003] = {monsters = {"Necropharus"}, telePos = {x = 33028, y = 32427, z = 12}, spawnPos = {x = 33028, y = 32421, z = 12}, from = {x = 33020, y = 32415, z = 12}, to = {x = 33035, y = 32430, z = 12}}, [14004] = {monsters = {"The Horned Fox"}, telePos = {x = 32458, y = 31993, z = 9}, spawnPos = {x = 32458, y = 32004, z = 9}, from = {x = 32453, y = 31992, z = 9}, to = {x = 32464, y = 32008, z = 9}}, [14005] = {monsters = {"Lethal Lissy", "Ron The Ripper", "Deadeye Devious", "Brutus Bloodbeard"}, telePos = {x = 31975, y = 32896, z = 0}, spawnPos = {x = 31982, y = 32896, z = 0}, from = {x = 31972, y = 32890, z = 0}, to = {x = 31988, y = 32904, z = 0}}, [14007] = {monsters = {"The Snapper"}, telePos = {x = 244, y = 647, z = 8}, spawnPos = {x = 236, y = 643, z = 8}, from = {x = 232, y = 640, z = 8}, to = {x = 245, y = 651, z = 8}}, [14008] = {monsters = {"Hide"}, telePos = {x = 32815, y = 32704, z = 8}, spawnPos = {x = 32816, y = 32708, z = 8}, from = {x = 32810, y = 32701, z = 8}, to = {x = 32824, y = 32713, z = 8}}, [14012] = {monsters = {"Shardhead"}, telePos = {x = 32102, y = 31125, z = 2}, spawnPos = {x = 32101, y = 31130, z = 2}, from = {x = 32095, y = 31122, z = 2}, to = {x = 32108, y = 31136, z = 2}}, [14019] = {monsters = {"Esmeralda"}, telePos = {x = 32759, y = 31253, z = 9}, spawnPos = {x = 32759, y = 31256, z = 9}, from = {x = 32755, y = 31250, z = 9}, to = {x = 32764, y = 31259, z = 9}}, [14020] = {monsters = {"The Old Widow"}, telePos = {x = 32804, y = 32280, z = 8}, spawnPos = {x = 32800, y = 32280, z = 8}, from = {x = 32794, y = 32273, z = 8}, to = {x = 32807, y = 32288, z = 8}}, [14021] = {monsters = {"The Many"}, telePos = {x = 32921, y = 32894, z = 8}, spawnPos = {x = 32921, y = 32899, z = 8}, from = {x = 32915, y = 32891, z = 8}, to = {x = 32927, y = 32904, z = 8}}, [14506] = {monsters = {"Demodras"}, telePos = {x = 32748, y = 32287, z = 10}, spawnPos = {x = 32745, y = 32292, z = 10}, from = {x = 32738, y = 32283, z = 10}, to = {x = 32757, y = 32300, z = 10}}, [14505] = {monsters = {"Tiquandas Revenge"}, telePos = {x = 32888, y = 32580, z = 4}, spawnPos = {x = 32883, y = 32580, z = 4}, from = {x = 32881, y = 32578, z = 4}, to = {x = 32892, y = 32588, z = 4}}, [14022] = {monsters = {"Stonecracker"}, telePos = {x = 33259, y = 31695, z = 15}, spawnPos = {x = 33257, y = 31702, z = 15}, from = {x = 33252, y = 31691, z = 15}, to = {x = 33266, y = 31708, z = 15}}, ]]-- } local function getCreaturesInArea(fromPos, toPos, creatureType) local creatures = {} for x = fromPos.x, toPos.x do for y = fromPos.y, toPos.y do for z = fromPos.z, toPos.z do local creature = getTopCreature({x = x, y = y, z = z}).uid local cType creatureType:lower() if (cType == "players" and isPlayer(creature)) then table.insert(creatures, creature) elseif (cType == "monsters" and isMonster(creature)) then table.insert(creatures, creature) elseif (cType == "npcs" and isNpc(creature)) then table.insert(creatures, creature) elseif (cType == "all") then table.insert(creatures, creature) end end end end return creatures end function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local now = teleports[item.uid] if now then local players = getPlayersInArea(now.from, now.to) if #players > 0 then doTeleportThing(cid, fromPosition, true) doPlayerSendCancel(cid, "Someone else is in the room.") return true end if getPlayerStorageValue(cid, item.uid + (item.uid < 14500 and 100 or 0)) == 1 then for _, monster in ipairs(getCreaturesInArea(now.from, now.to, "monsters")) do doRemoveCreature(monster) end setPlayerStorageValue(cid, item.uid + (item.uid < 14500 and 100 or 0), 2) doTeleportThing(cid, now.telePos) doSendMagicEffect(now.telePos, CONST_ME_TELEPORT) doSummonCreature(now.monsters[math.random(#now.monsters)], now.spawnPos) doSendMagicEffect(now.spawnPos, CONST_ME_TELEPORT) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You will be kicked from boss room in " .. timetokick[1] .. " "..timetokick[2]..".") addEvent(kickPlayerFromArea, mathtime(timetokick) * 1000, cid, {now.from, now.to, now.kickpos}) return true end end return true end function kickPlayerFromArea(cid, p) if isPlayer(cid) and isInRange(getPlayerPosition(cid), p[1], p[2]) then doTeleportThing(cid, p[3]) doSendMagicEffect(p[3], CONST_ME_TELEPORT) end end function getPlayersInArea(fromPos, toPos) local players = {} for _, pid in ipairs(getPlayersOnline()) do if isInRange(getPlayerPosition(pid), fromPos, toPos) then table.insert(players, pid) end end return players end function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end Contato: Email: [email protected] Discord: Dwarfer#2715
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.