Histórico de Curtidas
-
felipepalmas deu reputação a Mathias Kenfi em Alavanca IssaviVocê 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'
-
felipepalmas deu reputação a FlameArcixt em Alavanca IssaviAcho que serve, nao sou programador mas isso deve resolver, só mudar as posiçoes da sala
Tibiaking.lua
-
felipepalmas recebeu reputação de Cat em Alavanca IssaviSim, checar se tem player e mandar uma msg pra quem ta fora dizendo que já tem player na sala, eu já tentei usa getspectator , nao funciona.
-
felipepalmas deu reputação a FlameArcixt em Alavanca IssaviSe voce quer fazer com que o boos desapareça quando nao tiver mais gente na sala, voce precisa criar um creaturescript e registrar no monstro, e se quer que ele apareça pode ser por moveevent, quando ele passar por x tile o boos é sumonado, ou por creaturescript, quando entrar na sala ele é sumonado
PS: eu nao consigo ver as imagens que voce colocou de erro
-
felipepalmas recebeu reputação de Cat em Alavanca Issavi.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