Ir para conteúdo

Featured Replies

Postado
  • Solução
31 minutos atrás, leonardo gazim disse:

vodka, testei esse seu aqui e funcionou o player nao consegui entrar quando tem alguem na sala..mais tbm n esta sendo chutado para fora depois dos 10 minutos

 

achei que seu codigo ja fazia isso.

 

 

local config = {
	cooldown = 60 * 60 * 20, -- in seconds - (Make it 'seconds * minutes * hours' - its will be '60 * 60 * 20' for 20 hours) (player cooldown)
	cooldown_storage = 808856,
	storage_control = 78484,
	duration = 10, -- time till reset, in minutes (lever cooldown)
	level_req = 8, -- 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(33395, 32662, 6), toPos = Position(33395, 32658, 6)},
	[2] = {fromPos = Position(33395, 32663, 6), toPos = Position(33395, 32658, 6)},
	[3] = {fromPos = Position(33395, 32663, 6), toPos = Position(33395, 32658, 6)},
	[4] = {fromPos = Position(33395, 32665, 6), toPos = Position(33395, 32658, 6)},
	[5] = {fromPos = Position(33394, 32662, 6), toPos = Position(33395, 32658, 6)}
}
local monsters = {
	[1] = {pos = Position(33396, 32642, 6), name = "scarlett etzel"}
}
local quest_range = {fromPos = Position(33386, 32639, 6), toPos = Position(33405, 32659, 6)} -- see image in thread for explanation
local exit_position = Position(33395, 32671, 6) -- Position completely outside the quest area
function getPlayersInBossRoom()
	local spectators, t = Game.getSpectators(Position(33396, 32649, 6), false, false, 10, 10, 10, 10),{}
	for _, spectatorCreature in ipairs(spectators) do
		if spectatorCreature:isPlayer() then
			t[#t+1] = spectatorCreature
		end
	end
	return t
end
function doKickPlayerBoss(id)
	local players = getPlayersInBossRoom() 
	if #players == 0 then return true end
	if Game.getStorageValue(config.storage_control) == id then
			for _, cid in pairs(players) do
			       local participant = Player(cid)
			       participant:teleportTo(exit_position)
			       exit_position:sendMagicEffect(CONST_ME_TELEPORT)
				   participant:sendTextMessage(22,"voce nao matou o boss a tempo.")
			end
			Game.setStorageValue(config.storage_control, 0)
	end
end
function doResetTheBossDukeKrule(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

local function removeBoss()
	local specs, spec = Game.getSpectators(Position(33396, 32649, 6), false, false, 10, 10, 10, 10)
	for j = 1, #specs do
		spec = specs[j]
		if spec:getName():lower() == 'scarlett etzel' then
			spec:remove()
		end
	end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)	
	if player:getStorageValue(config.cooldown_storage) >= os.time() then
		player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "try tomorrow")
		return true
	end
		if #getPlayersInBossRoom() > 0 then
			return player:sendCancelMessage("ja exitem jogadores dentro do evento.")
		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
		removeBoss()
		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
		player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have 10 minutes to kill and loot this boss. Otherwise you will lose that chance and will be kicked out.")
	end	
	item:transform(config.pulled_id)
	player:setStorageValue(config.cooldown_storage, os.time() + config.cooldown)
	local r = math.random(1, 9999)
	Game.setStorageValue(config.storage_control, r)
	addEvent(doKickPlayerBoss, config.duration * 60 * 1000, r)
    addEvent(doResetTheBossDukeKrule, config.duration * 60 * 1000, toPosition, cid_array)	
	return true
end

 

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

  • Respostas 9
  • Visualizações 1.3k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • -- <action actionid="4627" event="script" value="bosses/scarlet_boss.lua"/> adicionar no actions.xml local posInicio = {x = 33385, y = 32638, z = 6} --pos inicio da sala local posFim = {x = 334

  • local config = { cooldown = 60 * 60 * 20, -- in seconds - (Make it 'seconds * minutes * hours' - its will be '60 * 60 * 20' for 20 hours) (player cooldown) cooldown_storage = 808856, duration = 10,

  • achei que seu codigo ja fazia isso.     local config = { cooldown = 60 * 60 * 20, -- in seconds - (Make it 'seconds * minutes * hours' - its will be '60 * 60 * 20' for 20 hours) (player

Postado
7 horas atrás, leonardo gazim disse:

vodka, testei esse seu aqui e funcionou o player nao consegui entrar quando tem alguem na sala..mais tbm n esta sendo chutado para fora depois dos 10 minutos

chego testar oque eu envie ?

Postado
  • Autor
9 horas atrás, Kenshiin disse:

chego testar oque eu envie ?

ainda nao,como nao estava com muito tempo para estar fazendo as mudanças dos locais e nomes testei so o do vodka que ja estava td no jeito,mais logo vou testar o seu tbm 
 

na vdd acho que o seu tbm esta ne kkk, acho que vi errado mais amanha testo sem falta

Editado por leonardo gazim (veja o histórico de edições)

Postado
  • Autor

kenshiin Testei aqui, quando uso a alavanca fala que eu nao posso usar o objeto, mesmo trocando o id da action para o que esta na alavanca no map

Postado
4 horas atrás, leonardo gazim disse:

kenshiin Testei aqui, quando uso a alavanca fala que eu nao posso usar o objeto, mesmo trocando o id da action para o que esta na alavanca no map

voce pode ter feito algo errado, porqe eu uso esse script, no servidor e nao tem erro nenhum confere tudo

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo