Ir para conteúdo
  • Cadastre-se

(Resolvido)Script Anihi Adicionar Coldown


Ir para solução Resolvido por Visitante,

Posts Recomendados

o script roda em tfs 1.3. mais preciso ajuda para colocar um coldoown pra poder fazer dnovo a quest. (configurable)
 

local config = {
    duration = 10, -- time till reset, in minutes
    level_req = 1, -- minimum level to do quest
    min_players = 1, -- minimum players to join quest
    lever_id = 1945, -- id of lever before pulled
    pulled_id = 1946 -- id of lever after pulled
}

local player_positions = {
    [1] = {fromPos = Position(928, 1015, 7), toPos = Position(919, 1020, 7)}
  --  [2] = {fromPos = Position(1000, 1000, 7), toPos = Position(1000, 1000, 7)},
  --  [3] = {fromPos = Position(1000, 1000, 7), toPos = Position(1000, 1000, 7)},
 --   [4] = {fromPos = Position(1000, 1000, 7), toPos = Position(1000, 1000, 7)}
}

local monsters = {
    [1] = {pos = Position(918, 1016, 7), name = "Orc"}
}

local quest_range = {fromPos = Position(913, 1013, 7), toPos = Position(925, 1020, 7)} -- see image in thread for explanation

local exit_position = Position(1000, 1000, 7) -- Position completely outside the quest area

function doResetAnnihilator(position, cid_array)
    local tile = Tile(position)
    local item = tile and tile:getItemById(config.pulled_id)
    if not item then
        return
    end

    local monster_names = {}
    for key, value in pairs(monsters) do
        if not isInArray(monster_names, value.name) then
            monster_names[#monster_names + 1] = value.name
        end
    end

    for i = 1, #monsters do
        local creatures = Tile(monsters[i].pos):getCreatures()
        for key, creature in pairs(creatures) do
            if isInArray(monster_names, creature:getName()) then
                creature:remove()
            end
        end
    end

    for i = 1, #player_positions do
        local creatures = Tile(player_positions[i].toPos):getCreatures()
        for key, creature in pairs(creatures) do
            if isInArray(monster_names, creature:getName()) then
                creature:remove()
            end
        end
    end

    for key, cid in pairs(cid_array) do
        local participant = Player(cid)
        if participant and isInRange(participant:getPosition(), quest_range.fromPos, quest_range.toPos) then
            participant:teleportTo(exit_position)
            exit_position:sendMagicEffect(CONST_ME_TELEPORT)
        end
    end

    item:transform(config.lever_id)
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid ~= config.lever_id then
        return player:sendCancelMessage("The quest is currently in use. Cooldown is " .. config.duration .. " minutes.")
    end

    local participants, pull_player = {}, false
    for i = 1, #player_positions do
        local fromPos = player_positions[i].fromPos
        local tile = Tile(fromPos)
        if not tile then
            print(">> ERROR: Annihilator tile does not exist for Position(" .. fromPos.x .. ", " .. fromPos.y .. ", " .. fromPos.z .. ").")
            return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
        end

        local creature = tile:getBottomCreature()
        if creature then
            local participant = creature:getPlayer()
            if not participant then
                return player:sendCancelMessage(participant:getName() .. " is not a valid participant.")
            end

            if participant:getLevel() < config.level_req then
                return player:sendCancelMessage(participant:getName() .. " is not the required level.")
            end

            if participant.uid == player.uid then
                pull_player = true
            end

            participants[#participants + 1] = {participant = participant, toPos = player_positions[i].toPos}
        end
    end

    if #participants < config.min_players then
        return player:sendCancelMessage("You do not have the required amount of participants.")
    end

    if not pull_player then
        return player:sendCancelMessage("You are in the wrong position.")
    end

    for i = 1, #monsters do
        local toPos = monsters[i].pos
        if not Tile(toPos) then
            print(">> ERROR: Annihilator tile does not exist for Position(" .. toPos.x .. ", " .. toPos.y .. ", " .. toPos.z .. ").")
            return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
        end
        Game.createMonster(monsters[i].name, monsters[i].pos, false, true)
    end

    local cid_array = {}
    for i = 1, #participants do
        participants[i].participant:teleportTo(participants[i].toPos)
        participants[i].toPos:sendMagicEffect(CONST_ME_TELEPORT)
        cid_array[#cid_array + 1] = participants[i].participant.uid
    end

    item:transform(config.pulled_id)
    addEvent(doResetAnnihilator, config.duration * 60 * 1000, toPosition, cid_array)
    return true
end

creditos do script : Apollos

Link para o post
Compartilhar em outros sites
  • Solução

@Chaotiick 

Usa esse ;D, bom proveito

Spoiler

local t = {
players = { -- posições que os players devem ficar ao puxar a alavanca
[1] = Position(33395,32661,6),
[2] = Position(33394,32662,6),
[3] = Position(33395,32662,6),
[4] = Position(33395,32663,6),
[5] = Position(33396,32662,6)
},

boss = {name = "Scarlett Etzel", create_pos = Position(33396,32642,6)},

destination = Position(33395,32656,6), -- posição para qual os players serão teleportados

cooldown = {0, "sec"}, -- 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)
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("One or all players did not wait " .. getStrTime(t.cooldown) .. " to go again.")
return true
end
for i = 1, #tab do
local playerTile = Tile(tab)
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: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 == 36319 or 1946 or 1945)
return true
end

local boss_room = {fromPos = Position(33386, 32639, 6), toPos = Position(33405, 32659, 6)}
local bossplayer = Player(cid)
local exit = Position(33395, 32659, 6)

if bossplayer and isInRange(bossplayer:getPosition(), boss_room.fromPos, boss_room.toPos) then
   bossplayer:teleportTo(exit)
        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

 

 

Link para o post
Compartilhar em outros sites
  • Erimyth mudou o título para Script Anihi Adicionar Coldown
18 horas atrás, Underewar disse:

@Chaotiick 

Usa esse ;D, bom proveito

  Ocultar conteúdo


local t = {
players = { -- posições que os players devem ficar ao puxar a alavanca
[1] = Position(33395,32661,6),
[2] = Position(33394,32662,6),
[3] = Position(33395,32662,6),
[4] = Position(33395,32663,6),
[5] = Position(33396,32662,6)
},

boss = {name = "Scarlett Etzel", create_pos = Position(33396,32642,6)},

destination = Position(33395,32656,6), -- posição para qual os players serão teleportados

cooldown = {0, "sec"}, -- 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)
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("One or all players did not wait " .. getStrTime(t.cooldown) .. " to go again.")
return true
end
for i = 1, #tab do
local playerTile = Tile(tab)
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: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 == 36319 or 1946 or 1945)
return true
end

local boss_room = {fromPos = Position(33386, 32639, 6), toPos = Position(33405, 32659, 6)}
local bossplayer = Player(cid)
local exit = Position(33395, 32659, 6)

if bossplayer and isInRange(bossplayer:getPosition(), boss_room.fromPos, boss_room.toPos) then
   bossplayer:teleportTo(exit)
        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

 

 

tentei mais so fala "One or all players did not wait "x time"
ja modifiquei as coordenadas. 
 

Spoiler

local t = {
players = { -- posições que os players devem ficar ao puxar a alavanca
[1] = Position(928, 1015, 7),
[2] = Position(928, 1016, 7),
[3] = Position(928, 1017, 7),
[4] = Position(928, 1018, 7),
[5] = Position(928, 1019, 7)
},

boss = {name = "Orc", create_pos = Position(918, 1016, 7)},

destination = Position(918, 1020, 7), -- posição para qual os players serão teleportados

cooldown = {0, "sec"}, -- 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)
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("One or all players did not wait " .. getStrTime(t.cooldown) .. " to go again.")
return true
end
for i = 1, #tab do
local playerTile = Tile(tab)
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: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 == 36319 or 1946 or 1945)
return true
end

local boss_room = {fromPos = Position(913, 1013, 7), toPos = Position(925, 1020, 7)}
local bossplayer = Player(cid)
local exit = Position(930, 1016, 7)

if bossplayer and isInRange(bossplayer:getPosition(), boss_room.fromPos, boss_room.toPos) then
   bossplayer:teleportTo(exit)
        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

asdsa.png

Editado por Chaotiick
falta do informacao (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

@Chaotiick Atualizei o código tenta esse

Spoiler

local config = {
	bossName = "Scarlett Etzel",
	lockStorage = 5000106, -- globalstorage
	bossPos = Position(33396, 32650, 6),
	centerRoom = Position(33396, 32641, 6), -- Center Room  
	exitPosition = Position(33393, 32661, 6), -- Exit Position
	newPos = Position(33396, 32650, 6),
	range = 1,
	time = 10, -- time in minutes to remove the player	
}	

--[[local monsters = {
	{pillar = "oberons ire", pos = Position(33367, 31320, 9)},
	{pillar = "oberons spite", pos = Position(33361, 31320, 9)},
	{pillar = "oberons hate", pos = Position( 33367, 31316, 9)},
	{pillar = "oberons bile", pos = Position(33361, 31316, 9)}
}]]

local function clearOberonRoom()
	if Game.getStorageValue(config.lockStorage) == 1 then
		local spectators = Game.getSpectators(config.bossPos, false, false, 10, 10, 10, 10)
		for i = 1, #spectators do
			local spectator = spectators[i]
			if spectator:isPlayer() then
				spectator:teleportTo(config.exitPosition)
				spectator:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
				spectator:say('Time out! You were teleported out by strange forces.', TALKTYPE_MONSTER_SAY)
			elseif spectator:isMonster() then
				spectator:remove()
			end
		end
		Game.setStorageValue(config.lockStorage, 0)
	end
end
-- Start Script
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
	if item.itemid == 36319 and item.actionid == 33300 then --- Posição de puxar alabanca
		if player:getPosition() ~= Position(33395, 32661, 6) then --- Posição de puxar alabanca
			return true
		end
			
	for x = 32662, 32662 do --Primeiro ao u ltimo tile onde os players ficam
	local playerTile = Tile(Position(x, 32661, 6)):getTopCreature()--Posição de puxar alavanca
		if playerTile and playerTile:isPlayer() then 
			if playerTile:getStorageValue(Storage.TheSecretLibrary.TheOrderOfTheFalcon.OberonTimer) > os.time() then
				playerTile:sendTextMessage(MESSAGE_STATUS_SMALL, "You or a member in your team have to wait 20 hours to challange Scarlet again!")
				item:transform(36319)
				return true
			end
		end
	end			
	
	local specs, spec = Game.getSpectators(config.centerRoom, false, false, 15, 15, 15, 15)
	for i = 1, #specs do
		spec = specs[i]
		if spec:isPlayer() then
			player:sendTextMessage(MESSAGE_STATUS_SMALL, "There's someone fighting with Scarlet.")
			item:transform(36319)
			return true
		end
	end	
			
	if Game.getStorageValue(config.lockStorage) == 1 then
		player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need wait 10 minutes to room cleaner!")
		return true
	end
	
	local spectators = Game.getSpectators(config.bossPos, false, false, 15, 15, 15, 15)
	for i = 1, #spectators do
		local spectator = spectators[i]
		if spectator:isMonster() then
			spectator:remove()
		end
	end
		--[[for n = 1, #monsters do
			Game.createMonster(monsters[n].pillar, monsters[n].pos, true, true)
		end]]	
	Game.createMonster(config.bossName, config.bossPos, true, true)	
	Game.setStorageValue(config.lockStorage, 1)
	for x = 32662, 32663 do --Primeiro ao ultimo tile dos player
		local playerTile = Tile(Position(x, 32661, 6)):getTopCreature()
		if playerTile and playerTile:isPlayer() then 					
			playerTile:getPosition():sendMagicEffect(CONST_ME_POFF)
			playerTile:teleportTo(config.newPos)
			playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT)	
			playerTile:setStorageValue(Storage.TheSecretLibrary.TheOrderOfTheFalcon.OberonTimer, os.time() + 20 * 60 * 3600) -- + 20 * 60 * 3600
			addEvent(clearOberonRoom, 60 * config.time * 1000, playerTile:getId(), config.centerRoom, config.range, config.range, config.exitPosition)
			playerTile:sendTextMessage(MESSAGE_STATUS_SMALL, "You have 10 minutes to kill and loot this boss. Otherwise you will lose that chance and will be kicked out.")
			item:transform(36319)
		end
	end
	
elseif item.itemid == 36319 then
		item:transform(36319)
	end
		return true
end

 

 

Link para o post
Compartilhar em outros sites

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.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo