Postado Outubro 3, 2020 4 anos 10 horas atrás, FlameArcixt disse: getSpectator é para cam, nao é isso que ele quer, ele quer que cheque se na area tem player, getSpectator só checaria se tivesse espectadores Você está equivocado, a função getSpectators faz uma checagem em uma area de acordo com os parâmetros fornecido e depois retorna um array com todas as criaturas encontradas. 11 horas atrás, felipepalmas disse: .Qual servidor ou website você utiliza como base? tfs 1.3 Qual o motivo deste tópico? Preciso que esse script verifique se tem players na room do boss e tbm que remova o boss caso o player saia da sala ou morra. Está surgindo algum erro? Se sim coloque-o aqui. Você tem o código disponível? Se tiver publique-o aqui: local t = { players = { -- posições que os players devem ficar ao puxar a alavanca [1] = Position(33918,31626,8), [2] = Position(33919,31626,8), [3] = Position(33920,31626,8), [4] = Position(33921,31626,8), [5] = Position(33922,31626,8) }, boss = {name = "Urmahlullu the Weakened", create_pos = Position(33919,31648,8)}, destination = Position(33919,31657,8), -- posição para qual os players serão teleportados cooldown = {4, "hour"}, -- tempo para ser teleportado novamente. Ex.: {2, "sec"}, {5, "min"}, {10, "hour"}, {3, "day"} storage = 56482 -- storage não utilizado no seu servidor } function onUse(player, item, fromPosition, target, toPosition, isHotkey) local players, tab = {}, t.players for i = 1, #tab do local tile = Tile(tab[i]) if tile then local p = Player(tile:getTopCreature()) if p then if p:getStorageValue(t.storage) <= os.time() then players[#players + 1] = p:getId() end end end end if #players == 0 then player:sendCancelMessage("Um ou mais players devem esperar " .. getStrTime(t.cooldown) .. " para fazer novamente.") return true end for i = 1, #tab do local playerTile = Tile(tab[i]) local playerToGo = Player(playerTile:getTopCreature()) if playerToGo then if isInArray(players, playerToGo:getId()) then playerToGo:setStorageValue(t.storage, mathtime(t.cooldown) + os.time()) playerTile:relocateTo(t.destination) tab[i]:sendMagicEffect(CONST_ME_POFF) end end end t.destination:sendMagicEffect(CONST_ME_TELEPORT) Game.createMonster(t.boss.name, t.boss.create_pos) item:transform(item.itemid == 1945 and 1946 or 1945) return true 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 function getStrTime(table) -- by dwarfer local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"} return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or "")) end local t = { players = { -- posições que os players devem ficar ao puxar a alavanca [1] = Position(33918,31626,8), [2] = Position(33919,31626,8), [3] = Position(33920,31626,8), [4] = Position(33921,31626,8), [5] = Position(33922,31626,8) }, boss = {name = "Urmahlullu the Weakened", create_pos = Position(33919,31648,8)}, destination = Position(33919,31657,8), -- posição para qual os players serão teleportados cooldown = {4, "hour"}, -- tempo para ser teleportado novamente. Ex.: {2, "sec"}, {5, "min"}, {10, "hour"}, {3, "day"} storage = 56482 -- storage não utilizado no seu servidor } -- Game.getSpectators(position[, multifloor = false[, onlyPlayer = false[, minRangeX = 0[, maxRangeX = 0[, minRangeY = 0[, maxRangeY = 0]]]]]]) function onUse(player, item, fromPosition, target, toPosition, isHotkey) local countPlayers = #Game.getSpectators(t.destination, false, true, 10, 10, 10, 10) -- Irá verificar se há players em um alcance de 10 por 10 com base na pos indicada no primeiro parâmetro if countPlayers > 0 then player:sendCancelMessage("Existem player emfrentando o boss, espere sua vez") return end local players, tab = {}, t.players for i = 1, #tab do local tile = Tile(tab[i]) if tile then local p = Player(tile:getTopCreature()) if p then if p:getStorageValue(t.storage) <= os.time() then players[#players + 1] = p:getId() end end end end if #players == 0 then player:sendCancelMessage("Um ou mais players devem esperar " .. getStrTime(t.cooldown) .. " para fazer novamente.") return true end for i = 1, #tab do local playerTile = Tile(tab[i]) local playerToGo = Player(playerTile:getTopCreature()) if playerToGo then if isInArray(players, playerToGo:getId()) then playerToGo:setStorageValue(t.storage, mathtime(t.cooldown) + os.time()) playerTile:relocateTo(t.destination) tab[i]:sendMagicEffect(CONST_ME_POFF) end end end t.destination:sendMagicEffect(CONST_ME_TELEPORT) Game.createMonster(t.boss.name, t.boss.create_pos) item:transform(item.itemid == 1945 and 1946 or 1945) return true 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 function getStrTime(table) -- by dwarfer local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"} return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or "")) end 11 horas atrás, FlameArcixt disse: A função que voce procura para checar os players na room é a isInRange(pos, fromPos, toPos) Mostrar conteúdo oculto EXEMPLO: if isInRange(getCreaturePosition(cid),{x = 967, y = 1037, z = 11},{x = 960, y = 1025, z = 11}) == 1 then doPlayerSendTextMessage(cid,20,"tem um player na area") else doPlayerSendTextMessage(cid,20,"Não tem player na area") end Essa função não verifica se tem players em uma area, ela verifica se a 'pos' está entre 'fromPos' e 'toPos' Editado Outubro 3, 2020 4 anos por Mathias Kenfi (veja o histórico de edições)
Postado Outubro 3, 2020 4 anos 1 hora atrás, Mathias Kenfi disse: Você está equivocado, a função getSpectators faz uma checagem em uma area de acordo com os parâmetros fornecido e depois retorna um array com todas as criaturas encontradas. local t = { players = { -- posições que os players devem ficar ao puxar a alavanca [1] = Position(33918,31626,8), [2] = Position(33919,31626,8), [3] = Position(33920,31626,8), [4] = Position(33921,31626,8), [5] = Position(33922,31626,8) }, boss = {name = "Urmahlullu the Weakened", create_pos = Position(33919,31648,8)}, destination = Position(33919,31657,8), -- posição para qual os players serão teleportados cooldown = {4, "hour"}, -- tempo para ser teleportado novamente. Ex.: {2, "sec"}, {5, "min"}, {10, "hour"}, {3, "day"} storage = 56482 -- storage não utilizado no seu servidor } -- Game.getSpectators(position[, multifloor = false[, onlyPlayer = false[, minRangeX = 0[, maxRangeX = 0[, minRangeY = 0[, maxRangeY = 0]]]]]]) function onUse(player, item, fromPosition, target, toPosition, isHotkey) local countPlayers = #Game.getSpectators(t.destination, false, true, 10, 10, 10, 10) -- Irá verificar se há players em um alcance de 10 por 10 com base na pos indicada no primeiro parâmetro if countPlayers > 0 then player:sendCancelMessage("Existem player emfrentando o boss, espere sua vez") return end local players, tab = {}, t.players for i = 1, #tab do local tile = Tile(tab[i]) if tile then local p = Player(tile:getTopCreature()) if p then if p:getStorageValue(t.storage) <= os.time() then players[#players + 1] = p:getId() end end end end if #players == 0 then player:sendCancelMessage("Um ou mais players devem esperar " .. getStrTime(t.cooldown) .. " para fazer novamente.") return true end for i = 1, #tab do local playerTile = Tile(tab[i]) local playerToGo = Player(playerTile:getTopCreature()) if playerToGo then if isInArray(players, playerToGo:getId()) then playerToGo:setStorageValue(t.storage, mathtime(t.cooldown) + os.time()) playerTile:relocateTo(t.destination) tab[i]:sendMagicEffect(CONST_ME_POFF) end end end t.destination:sendMagicEffect(CONST_ME_TELEPORT) Game.createMonster(t.boss.name, t.boss.create_pos) item:transform(item.itemid == 1945 and 1946 or 1945) return true 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 function getStrTime(table) -- by dwarfer local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"} return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or "")) end Essa função não verifica se tem players em uma area, ela verifica se a 'pos' está entre 'fromPos' e 'toPos' Não sabia disso,sempre usei pra checar se tem player na area
Postado Outubro 5, 2020 4 anos Autor Em 03/10/2020 em 11:40, Mathias Kenfi disse: Você está equivocado, a função getSpectators faz uma checagem em uma area de acordo com os parâmetros fornecido e depois retorna um array com todas as criaturas encontradas. local t = { players = { -- posições que os players devem ficar ao puxar a alavanca [1] = Position(33918,31626,8), [2] = Position(33919,31626,8), [3] = Position(33920,31626,8), [4] = Position(33921,31626,8), [5] = Position(33922,31626,8) }, boss = {name = "Urmahlullu the Weakened", create_pos = Position(33919,31648,8)}, destination = Position(33919,31657,8), -- posição para qual os players serão teleportados cooldown = {4, "hour"}, -- tempo para ser teleportado novamente. Ex.: {2, "sec"}, {5, "min"}, {10, "hour"}, {3, "day"} storage = 56482 -- storage não utilizado no seu servidor } -- Game.getSpectators(position[, multifloor = false[, onlyPlayer = false[, minRangeX = 0[, maxRangeX = 0[, minRangeY = 0[, maxRangeY = 0]]]]]]) function onUse(player, item, fromPosition, target, toPosition, isHotkey) local countPlayers = #Game.getSpectators(t.destination, false, true, 10, 10, 10, 10) -- Irá verificar se há players em um alcance de 10 por 10 com base na pos indicada no primeiro parâmetro if countPlayers > 0 then player:sendCancelMessage("Existem player emfrentando o boss, espere sua vez") return end local players, tab = {}, t.players for i = 1, #tab do local tile = Tile(tab[i]) if tile then local p = Player(tile:getTopCreature()) if p then if p:getStorageValue(t.storage) <= os.time() then players[#players + 1] = p:getId() end end end end if #players == 0 then player:sendCancelMessage("Um ou mais players devem esperar " .. getStrTime(t.cooldown) .. " para fazer novamente.") return true end for i = 1, #tab do local playerTile = Tile(tab[i]) local playerToGo = Player(playerTile:getTopCreature()) if playerToGo then if isInArray(players, playerToGo:getId()) then playerToGo:setStorageValue(t.storage, mathtime(t.cooldown) + os.time()) playerTile:relocateTo(t.destination) tab[i]:sendMagicEffect(CONST_ME_POFF) end end end t.destination:sendMagicEffect(CONST_ME_TELEPORT) Game.createMonster(t.boss.name, t.boss.create_pos) item:transform(item.itemid == 1945 and 1946 or 1945) return true 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 function getStrTime(table) -- by dwarfer local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"} return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or "")) end Essa função não verifica se tem players em uma area, ela verifica se a 'pos' está entre 'fromPos' e 'toPos' Boa tarde amigo, a alteração que vc fez no script funcionou, porem a mensagem avisando que tem player não é mandada aos players . Oque será que pode ser isso? Edit: consegui fazer funcionar, faltava so um return true. Me diz uma coisa, qual a função eu uso pra remover o boss ou dar um clear room, caso quem entre não consiga matar ou morra pra boss ? Editado Outubro 5, 2020 4 anos por felipepalmas Consegui fazer funcionar (veja o histórico de edições)
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.