markim1986 2 Postado Janeiro 8, 2013 Share Postado Janeiro 8, 2013 Nome do Script: Script de Teleport quando o monstro na area "x" a "y" estiver mortos. Tipo do Script: Nao sei! Versão Utilizada: 8.60 Servidor Utilizado: TheLostServer Nível de Experiência: Complicado. Informações Extras: -- Gostaria de um script no qual o teleporte so ficase disponivel no local "X" apenas quando na area "y" a "Z" nao houver monstros. Ex: Numa pequena cav de demon o portal só ficará aberto para se retirar da cave quando nao houver mais demons vivos. Obs: Ja procurei no forum esse eskema e não encontrei. Agradeço Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/ Compartilhar em outros sites More sharing options...
0 SmiX 265 Postado Janeiro 8, 2013 Share Postado Janeiro 8, 2013 Não testado: data/creaturescripts/scripts/killMonsterInArea.lua local config = { position_initial = {x=1, y=2, z=3}, -- Posição superior direita da sala position_end = {x=4, y=5, z=6}, -- Posição inferior direita da sala corpses_id = {2916, 2917, 2918, 2919}, -- Todos os ids do corpses posicao_of_teleport = {x=7, y=8, z=9}, -- Posição para onde o teleporte vai mandar o player teleport_actionid = 1837, -- Actionid do telport, não precisa colocar esse id no mapa editor. } function onDeath(cid) for x = config.position_initial.x, config.position_end.x do for y = config.position_initial.y, config.position_end.y do for z = config.position_initial.z, config.position_end.z do forArea = {x = x, y = y, z = z, stackpos = 253} getCorpses = getThingFromPos(forArea) if isMonster(getCorpses.uid) then break end for i = 1, #config.corpses_id do if isInArray(getCorpses.uid, getTileItemById(getCorpses, i)) then local teleport = doCreateTeleport(1387, config.posicao_of_teleport, config.posicao_of_teleport) doItemSetAttribute(teleport, "aid", config.teleport_actionid) end end end end end end tag: <event type="death" name="monsterKillInArea" event="script" value="killMonsterInArea.lua"/> Agora vai no arquivo do 'demon' depois de: <loot> </loot> adicione essas linhas: <script> <event name="monsterKillInArea"/> </script> Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/#findComment-1433718 Compartilhar em outros sites More sharing options...
0 markim1986 2 Postado Janeiro 8, 2013 Autor Share Postado Janeiro 8, 2013 Brother nessa linha: position_initial = {x=1, y=2, z=3}, -- Posição superior direita da sala position_end = {x=4, y=5, z=6}, -- Posição inferior direita da sala Nao era pra ser assim nao ? position_initial = {x=1, y=2, z=3}, -- Posição superior direita da sala position_end = {x=4, y=5, z=6}, -- Posição inferior esquerda da sala e aonde esta a linha de posição do portal para ele nascer? No seu script só tem para aonde ele vai levar o player, e pq eu nao tenho que colocar o ActionID no portal pelo map editor? Como ele vai reconhecer? Nesta linha <script> <event name="monsterKillInArea"/> </script> Tem certeza que é isso mesmo ? Pq a linha esta preta aki visualizando pelo notepad++ ou seja nao esta fechando comando. Obrigado Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/#findComment-1433867 Compartilhar em outros sites More sharing options...
0 Oneshot 732 Postado Janeiro 8, 2013 Share Postado Janeiro 8, 2013 local areas = { [1] = { fromPosition = {x = 93, y = 125, z = 7}, -- upper-left sqm toPosition = {x = 95, y = 127, z = 7}, -- lower-right sqm creatureName = "Rat" } } function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local pass = true for _, area in ipairs(areas) do local x = {min = math.min(area.fromPosition.x, area.toPosition.x), max = math.max(area.fromPosition.x, area.toPosition.x)} local y = {min = math.min(area.fromPosition.y, area.toPosition.y), max = math.max(area.fromPosition.y, area.toPosition.y)} local width = ((x.max - x.min) / 2) + 1 local lenght = ((y.max - y.min) / 2) + 1 local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z} local specs = getSpectators(center, width, lenght, false) if specs then for _, cn in ipairs(specs) do if getCreatureName(cn):lower() == area.creatureName:lower() then pass = false break end end end end if pass == false then doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.") doTeleportThing(cid, fromPosition, true) end return true end É um movement, no caso, estou considerando que o teleport já existe com um actionid no mapa. <movevent type="StepIn" actionid="20000" event="script" value="nome_do_arquivo.lua"/> Abraços. Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/#findComment-1433880 Compartilhar em outros sites More sharing options...
0 nathygyn 1 Postado Janeiro 8, 2013 Share Postado Janeiro 8, 2013 Se alguém testar e puder falar, é útil pra mim também. Não testo porque não entendo nada :x Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/#findComment-1433882 Compartilhar em outros sites More sharing options...
0 markim1986 2 Postado Janeiro 8, 2013 Autor Share Postado Janeiro 8, 2013 (editado) local areas = { [1] = { fromPosition = {x = 93, y = 125, z = 7}, -- upper-left sqm toPosition = {x = 95, y = 127, z = 7}, -- lower-right sqm creatureName = "Rat" } } function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local pass = true for _, area in ipairs(areas) do local x = {min = math.min(area.fromPosition.x, area.toPosition.x), max = math.max(area.fromPosition.x, area.toPosition.x)} local y = {min = math.min(area.fromPosition.y, area.toPosition.y), max = math.max(area.fromPosition.y, area.toPosition.y)} local width = ((x.max - x.min) / 2) + 1 local lenght = ((y.max - y.min) / 2) + 1 local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z} local specs = getSpectators(center, width, lenght, false) if specs then for _, cn in ipairs(specs) do if getCreatureName(cn):lower() == area.creatureName:lower() then pass = false break end end end end if pass == false then doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.") doTeleportThing(cid, fromPosition, true) end return true end É um movement, no caso, estou considerando que o teleport já existe com um actionid no mapa. <movevent type="StepIn" actionid="20000" event="script" value="nome_do_arquivo.lua"/> Abraços. Cara acabei de testar O portal ja esta criando com a coordenada para ir em bora e com o actrionID "20054" e o portal esta acessível com ou sem bixo na area, segue os scripts adicionados. TP.lua local areas = { [1] = { fromPosition = {x = 1522, y = 1026, z = 7}, -- upper-left sqm toPosition = {x = 1535, y = 1034, z = 7}, -- lower-right sqm creatureName = "Rat" } }[/size][/color] [color="#282828"][size=2]function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local pass = true for _, area in ipairs(areas) do local x = {min = math.min(area.fromPosition.x, area.toPosition.x), max = math.max(area.fromPosition.x, area.toPosition.x)} local y = {min = math.min(area.fromPosition.y, area.toPosition.y), max = math.max(area.fromPosition.y, area.toPosition.y)}[/size][/color] [color="#282828"][size=2] local width = ((x.max - x.min) / 2) + 1 local lenght = ((y.max - y.min) / 2) + 1[/size][/color] [color="#282828"][size=2] local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z} local specs = getSpectators(center, width, lenght, false) if specs then for _, cn in ipairs(specs) do if getCreatureName(cn):lower() == area.creatureName:lower() then pass = false break end end end end[/size][/color] [color="#282828"][size=2] if pass == false then doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.") doTeleportThing(cid, fromPosition, true) end return true end Moviments.xml <movevent type="StepIn" actionid="20054" event="script" value="tp.lua"/> Editado Janeiro 8, 2013 por markim1986 Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/#findComment-1433903 Compartilhar em outros sites More sharing options...
0 brun123 369 Postado Janeiro 8, 2013 Share Postado Janeiro 8, 2013 Teste trocar: doTeleportThing(cid, fromPosition, true) para: addEvent(doTeleportThing, 5, cid, fromPosition, true) Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/#findComment-1433998 Compartilhar em outros sites More sharing options...
0 Oneshot 732 Postado Janeiro 8, 2013 Share Postado Janeiro 8, 2013 (editado) Esqueci de colocar return false local areas = { [1] = { fromPosition = {x = 93, y = 125, z = 7}, -- upper-left sqm toPosition = {x = 95, y = 127, z = 7}, -- lower-right sqm creatureName = "Rat" } } function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local pass = true for _, area in ipairs(areas) do local x = {min = math.min(area.fromPosition.x, area.toPosition.x), max = math.max(area.fromPosition.x, area.toPosition.x)} local y = {min = math.min(area.fromPosition.y, area.toPosition.y), max = math.max(area.fromPosition.y, area.toPosition.y)} local width = ((x.max - x.min) / 2) + 1 local lenght = ((y.max - y.min) / 2) + 1 local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z} local specs = getSpectators(center, width, lenght, false) if specs then for _, cn in ipairs(specs) do if getCreatureName(cn):lower() == area.creatureName:lower() then pass = false break end end end end if pass == false then doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.") doTeleportThing(cid, fromPosition, true) return false end return true end Editado Janeiro 8, 2013 por Oneshot Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/#findComment-1434025 Compartilhar em outros sites More sharing options...
0 markim1986 2 Postado Janeiro 8, 2013 Autor Share Postado Janeiro 8, 2013 Perfeito so uma ultima coisa como faço para colocar essa proteção para mais monstros ex: creatureName = "Rat" Como seria pra adicionar uma proteção de Rat e Cave Rat? Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/#findComment-1434216 Compartilhar em outros sites More sharing options...
0 Oneshot 732 Postado Janeiro 8, 2013 Share Postado Janeiro 8, 2013 local areas = { [1] = { fromPosition = {x = 100, y = 100, z = 7} -- upper-left sqm toPosition = {x = 100, y = 100, z = 7} -- lower-right sqm creatureName = {"Rat", "Cave Rat"} } } function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local pass = true for _, area in ipairs(areas) do local x = {} x.min = math.min(area.fromPosition.x, area.toPosition.x) x.max = math.max(area.fromPosition.x, area.toPosition.x) local y = {} y.min = math.min(area.fromPosition.y, area.toPosition.y) y.max = math.max(area.fromPosition.y, area.toPosition.y) local width = ((x.max - x.min) / 2) + 1 local lenght = ((y.max - y.min) / 2) + 1 local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z} for _, creature in ipairs(getSpectators(center, width, lenght, false)) do if (type(area.creatureName) == "table" and isInArray(area.creatureName, getCreatureName(creature):lower())) or getCreatureName(creature):lower == area:creatureName:lower() then pass = false break end end end if pass == false then doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.") doTeleportThing(cid, fromPosition, true) return false end return true end Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/#findComment-1434226 Compartilhar em outros sites More sharing options...
0 markim1986 2 Postado Janeiro 8, 2013 Autor Share Postado Janeiro 8, 2013 local areas = { [1] = { fromPosition = {x = 100, y = 100, z = 7} -- upper-left sqm toPosition = {x = 100, y = 100, z = 7} -- lower-right sqm creatureName = {"Rat", "Cave Rat"} } } function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local pass = true for _, area in ipairs(areas) do local x = {} x.min = math.min(area.fromPosition.x, area.toPosition.x) x.max = math.max(area.fromPosition.x, area.toPosition.x) local y = {} y.min = math.min(area.fromPosition.y, area.toPosition.y) y.max = math.max(area.fromPosition.y, area.toPosition.y) local width = ((x.max - x.min) / 2) + 1 local lenght = ((y.max - y.min) / 2) + 1 local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z} for _, creature in ipairs(getSpectators(center, width, lenght, false)) do if (type(area.creatureName) == "table" and isInArray(area.creatureName, getCreatureName(creature):lower())) or getCreatureName(creature):lower == area:creatureName:lower() then pass = false break end end end if pass == false then doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.") doTeleportThing(cid, fromPosition, true) return false end return true end Deu erro na hora de iniciar o server, segue o mesmo abaixo: [17/01/2013 20:19:53] [Error - LuaScriptInterface::loadFile] data/movements/scripts/travarespow.lua:4: '}' expected (to close '{' at line 2) near 'toPosition' [17/01/2013 20:19:53] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/travarespow.lua) [17/01/2013 20:19:53] data/movements/scripts/travarespow.lua:4: '}' expected (to close '{' at line 2) near 'toPosition' [17/01/2013 20:19:53] Reloaded movements. Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/#findComment-1434238 Compartilhar em outros sites More sharing options...
0 Oneshot 732 Postado Janeiro 8, 2013 Share Postado Janeiro 8, 2013 (editado) local areas = { [1] = { fromPosition = {x = 93, y = 125, z = 7}, -- upper-left sqm toPosition = {x = 95, y = 127, z = 7}, -- lower-right sqm creatureName = {"Rat", "Cave Rat"} } } function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local pass = true for _, area in ipairs(areas) do local x = {min = math.min(area.fromPosition.x, area.toPosition.x), max = math.max(area.fromPosition.x, area.toPosition.x)} local y = {min = math.min(area.fromPosition.y, area.toPosition.y), max = math.max(area.fromPosition.y, area.toPosition.y)} local width = ((x.max - x.min) / 2) + 1 local lenght = ((y.max - y.min) / 2) + 1 local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z} local specs = getSpectators(center, width, lenght, false) if specs then for _, cn in ipairs(specs) do if (type(area.creatureName) == "table" and isInArray(area.creatureName, getCreatureName(cn))) or getCreatureName(cn):lower() == area.creatureName:lower() then pass = false break end end end end if pass == false then doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.") doTeleportThing(cid, fromPosition, true) end return true end Editado Janeiro 8, 2013 por Oneshot Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/#findComment-1434242 Compartilhar em outros sites More sharing options...
0 markim1986 2 Postado Janeiro 8, 2013 Autor Share Postado Janeiro 8, 2013 local areas = { [1] = { fromPosition = {x = 93, y = 125, z = 7}, -- upper-left sqm toPosition = {x = 95, y = 127, z = 7}, -- lower-right sqm creatureName = {"Rat", "Cave Rat"} } } function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local pass = true for _, area in ipairs(areas) do local x = {min = math.min(area.fromPosition.x, area.toPosition.x), max = math.max(area.fromPosition.x, area.toPosition.x)} local y = {min = math.min(area.fromPosition.y, area.toPosition.y), max = math.max(area.fromPosition.y, area.toPosition.y)} local width = ((x.max - x.min) / 2) + 1 local lenght = ((y.max - y.min) / 2) + 1 local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z} local specs = getSpectators(center, width, lenght, false) if specs then for _, cn in ipairs(specs) do if (type(area.creatureName) == "table" and isInArray(area.creatureName, getCreatureName(cn))) or getCreatureName(cn):lower() == area.creatureName:lower() then pass = false break end end end end if pass == false then doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.") doTeleportThing(cid, fromPosition, true) end return true end Esse erro quando inicia o server. [17/01/2013 20:51:04] [Error - LuaScriptInterface::loadFile] data/movements/scripts/travarespow.lua:22: function arguments expected near '==' [17/01/2013 20:51:04] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/travarespow.lua) [17/01/2013 20:51:04] data/movements/scripts/travarespow.lua:22: function arguments expected near '==' [17/01/2013 20:51:04] Reloaded movements. Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/#findComment-1434254 Compartilhar em outros sites More sharing options...
0 Oneshot 732 Postado Janeiro 8, 2013 Share Postado Janeiro 8, 2013 Eu testei aqui, está funcionando normal, copie o script corretamente do post acima. Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/#findComment-1434261 Compartilhar em outros sites More sharing options...
0 markim1986 2 Postado Janeiro 8, 2013 Autor Share Postado Janeiro 8, 2013 Eu testei aqui, está funcionando normal, copie o script corretamente do post acima. Realmente tinha sido erro meu, mas ainda pesiste o erro: [17/01/2013 21:34:29] [Error - MoveEvents Interface] [17/01/2013 21:34:29] data/movements/scripts/travarespow.lua:onStepIn [17/01/2013 21:34:29] Description: [17/01/2013 21:34:29] data/movements/scripts/travarespow.lua:22: attempt to call method 'lower' (a nil value) [17/01/2013 21:34:29] stack traceback: [17/01/2013 21:34:29] data/movements/scripts/travarespow.lua:22: in function <data/movements/scripts/travarespow.lua:9> o mesmo acontece quando o cave rat esta na area ou seja, quando esta somente o Rat eu nao passo no teleport, quando esta somente o Cave Rat eu passo no teleporte e vem o erro esposto acima! Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/#findComment-1434282 Compartilhar em outros sites More sharing options...
0 brun123 369 Postado Janeiro 9, 2013 Share Postado Janeiro 9, 2013 local areas = { [1] = { fromPosition = {x = 93, y = 125, z = 7}, -- upper-left sqm toPosition = {x = 95, y = 127, z = 7}, -- lower-right sqm creatureName = {"Rat", "Cave Rat"} } } function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local pass = true for _, area in ipairs(areas) do local x = {min = math.min(area.fromPosition.x, area.toPosition.x), max = math.max(area.fromPosition.x, area.toPosition.x)} local y = {min = math.min(area.fromPosition.y, area.toPosition.y), max = math.max(area.fromPosition.y, area.toPosition.y)} local width = ((x.max - x.min) / 2) + 1 local lenght = ((y.max - y.min) / 2) + 1 local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z} local specs = getSpectators(center, width, lenght, false) if specs then for _, cn in ipairs(specs) do if type(area.creatureName) == "table" and isInArray(area.creatureName, getCreatureName(cn)) then pass = false break elseif getCreatureName(cn):lower() == area.creatureName:lower() then pass = false break end end end end if pass == false then doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.") doTeleportThing(cid, fromPosition, true) return false end return true end Link para o comentário https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/#findComment-1434456 Compartilhar em outros sites More sharing options...
Pergunta
markim1986 2
Nome do Script: Script de Teleport quando o monstro na area "x" a "y" estiver mortos.
Tipo do Script: Nao sei!
Versão Utilizada: 8.60
Servidor Utilizado: TheLostServer
Nível de Experiência: Complicado.
Informações Extras: --
Gostaria de um script no qual o teleporte so ficase disponivel no local "X" apenas quando na area "y" a "Z" nao houver monstros.
Ex: Numa pequena cav de demon o portal só ficará aberto para se retirar da cave quando nao houver mais demons vivos.
Obs: Ja procurei no forum esse eskema e não encontrei.
Agradeço
Link para o comentário
https://xtibia.com/forum/topic/203717-script-de-teleport-quando-o-monstro-na-area-x-a-y-estiver-mortos/Compartilhar em outros sites
20 respostass a esta questão
Posts Recomendados