Ir para conteúdo

Featured Replies

Postado
  • Autor
33 minutos atrás, Vodkart disse:

refiz o sistema:

 


-- LIB
hunt_config = {
	storage = 789456,
	from = {x = 1739, y = 358, z = 7}, -- coordenada do canto superior esquerdo da área.
	to = {x = 1844, y = 453, z = 7}, -- coordenada do canto inferior direito da área.
	maxPlayers = 2, -- quantos jogadores poderão entrar na área ao mesmo tempo.
	pos = {x = 1739, y = 397, z = 7}, -- para onde o jogador será teleportado.
	exit = {x = 1005, y = 905, z = 5}
}

-- MOVEMENTS
function onStepIn(cid, item, position, fromPosition)
	local t = {} 
	if not isPlayer(cid) then return true end
	for _, pid in pairs(getPlayersOnline()) do
		if isInRange(getPlayerPosition(pid), hunt_config.from, hunt_config.to) then 
			t[#t+1] = pid
		end
	end
	if #t >= hunt_config.maxPlayers then
		doPlayerSendTextMessage (cid, 19, "Essa hunt ja atingiu o numero maximo de jogadores, aguarde um pouco.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
		doTeleportThing(cid, fromPosition, true)
	elseif getPlayerStorageValue(cid, hunt_config.storage) - os.time() <= 0 then
		doPlayerSendTextMessage(cid, 19, "Voce nao tem acesso a essa hunt, fale com o npc no segundo andar para adquirir uma.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
		doTeleportThing(cid, fromPosition, true)
	else
		
		doTeleportThing(cid, hunt_config.pos)
		doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
	end
	return true
end

-- ACTION

function onUse(cid, item, frompos, item2, topos)
	local config = {
		timeExhausted = 12, -- tempo em horas para poder usar o item novamente.
		timeForUse = 1, -- tempo em horas que o player poderá entrar na cave.
		exhausted = 456789,
	}
	if getPlayerStorageValue(cid, config.exhausted) - os.time() > 0 then
		doPlayerSendTextMessage(cid, 19, "Aguarde 12 horas para usar esse item novamente.") return true
	end
	setPlayerStorageValue(cid, hunt_config.storage, os.time()+config.timeForUse*3600)
	setPlayerStorageValue(cid, config.exhausted, os.time()+config.timeExhausted*3600)
	doSendMagicEffect(getThingPos(cid), 27)
	doPlayerSendTextMessage(cid, 19, "Parabéns voce tem o acesso a hunt exclusiva N-2 por 1 horas.")
	doRemoveItem(item.uid)
	return true
end

--GLOBAL
function onThink(interval, lastExecution)
	local on = getPlayersOnline()
	if #on > 0 then
		for _, pid in pairs(on) do
			if isInRange(getPlayerPosition(pid), hunt_config.from, hunt_config.to) and getPlayerStorageValue(pid, hunt_config.storage) - os.time() <= 0 then
				doTeleportThing(pid, hunt_config.exit)
				doPlayerSendTextMessage(pid, 19, "tempo esgotado.")
			end
		end
	end
	return true
end

 

 

 

para testar mais rapido usa assim no actions nessa linha:

 


setPlayerStorageValue(cid, hunt_config.storage, os.time()+90) -- 90 segundos de sistema

 

Essa lib, tenho que criar uma nova quando eu for add uma outra hunt?

Agora, leozincorsair disse:

Essa lib, tenho que criar uma nova quando eu for add uma outra hunt?

tenho 6 hunts pra fazer assim, e desse jeito so consigo configurar uma na pasta lib

  • Respostas 26
  • Visualizações 2.1k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • tem que funcionar viado, ta td certo... me chama discord to on   @So volto tarde   nesse caso não... pois só está pegando a pos númerica dos jogadores... agr se for td hr checar var

Posted Images

Postado
  • Autor
Em 01/12/2021 em 15:27, Vodkart disse:

refiz o sistema:

 


-- LIB
hunt_config = {
	storage = 789456,
	from = {x = 1739, y = 358, z = 7}, -- coordenada do canto superior esquerdo da área.
	to = {x = 1844, y = 453, z = 7}, -- coordenada do canto inferior direito da área.
	maxPlayers = 2, -- quantos jogadores poderão entrar na área ao mesmo tempo.
	pos = {x = 1739, y = 397, z = 7}, -- para onde o jogador será teleportado.
	exit = {x = 1005, y = 905, z = 5}
}

-- MOVEMENTS
function onStepIn(cid, item, position, fromPosition)
	local t = {} 
	if not isPlayer(cid) then return true end
	for _, pid in pairs(getPlayersOnline()) do
		if isInRange(getPlayerPosition(pid), hunt_config.from, hunt_config.to) then 
			t[#t+1] = pid
		end
	end
	if #t >= hunt_config.maxPlayers then
		doPlayerSendTextMessage (cid, 19, "Essa hunt ja atingiu o numero maximo de jogadores, aguarde um pouco.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
		doTeleportThing(cid, fromPosition, true)
	elseif getPlayerStorageValue(cid, hunt_config.storage) - os.time() <= 0 then
		doPlayerSendTextMessage(cid, 19, "Voce nao tem acesso a essa hunt, fale com o npc no segundo andar para adquirir uma.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
		doTeleportThing(cid, fromPosition, true)
	else
		
		doTeleportThing(cid, hunt_config.pos)
		doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
	end
	return true
end

-- ACTION

function onUse(cid, item, frompos, item2, topos)
	local config = {
		timeExhausted = 12, -- tempo em horas para poder usar o item novamente.
		timeForUse = 1, -- tempo em horas que o player poderá entrar na cave.
		exhausted = 456789,
	}
	if getPlayerStorageValue(cid, config.exhausted) - os.time() > 0 then
		doPlayerSendTextMessage(cid, 19, "Aguarde 12 horas para usar esse item novamente.") return true
	end
	setPlayerStorageValue(cid, hunt_config.storage, os.time()+config.timeForUse*3600)
	setPlayerStorageValue(cid, config.exhausted, os.time()+config.timeExhausted*3600)
	doSendMagicEffect(getThingPos(cid), 27)
	doPlayerSendTextMessage(cid, 19, "Parabéns voce tem o acesso a hunt exclusiva N-2 por 1 horas.")
	doRemoveItem(item.uid)
	return true
end

--GLOBAL
function onThink(interval, lastExecution)
	local on = getPlayersOnline()
	if #on > 0 then
		for _, pid in pairs(on) do
			if isInRange(getPlayerPosition(pid), hunt_config.from, hunt_config.to) and getPlayerStorageValue(pid, hunt_config.storage) - os.time() <= 0 then
				doTeleportThing(pid, hunt_config.exit)
				doPlayerSendTextMessage(pid, 19, "tempo esgotado.")
			end
		end
	end
	return true
end

 

 

 

para testar mais rapido usa assim no actions nessa linha:

 


setPlayerStorageValue(cid, hunt_config.storage, os.time()+90) -- 90 segundos de sistema

 

Funcionou , agora sé possível adaptar para eu adicionar mais hunts.

Postado
  • Autor
Em 01/12/2021 em 15:27, Vodkart disse:

refiz o sistema:

 


-- LIB
hunt_config = {
	storage = 789456,
	from = {x = 1739, y = 358, z = 7}, -- coordenada do canto superior esquerdo da área.
	to = {x = 1844, y = 453, z = 7}, -- coordenada do canto inferior direito da área.
	maxPlayers = 2, -- quantos jogadores poderão entrar na área ao mesmo tempo.
	pos = {x = 1739, y = 397, z = 7}, -- para onde o jogador será teleportado.
	exit = {x = 1005, y = 905, z = 5}
}

-- MOVEMENTS
function onStepIn(cid, item, position, fromPosition)
	local t = {} 
	if not isPlayer(cid) then return true end
	for _, pid in pairs(getPlayersOnline()) do
		if isInRange(getPlayerPosition(pid), hunt_config.from, hunt_config.to) then 
			t[#t+1] = pid
		end
	end
	if #t >= hunt_config.maxPlayers then
		doPlayerSendTextMessage (cid, 19, "Essa hunt ja atingiu o numero maximo de jogadores, aguarde um pouco.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
		doTeleportThing(cid, fromPosition, true)
	elseif getPlayerStorageValue(cid, hunt_config.storage) - os.time() <= 0 then
		doPlayerSendTextMessage(cid, 19, "Voce nao tem acesso a essa hunt, fale com o npc no segundo andar para adquirir uma.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
		doTeleportThing(cid, fromPosition, true)
	else
		
		doTeleportThing(cid, hunt_config.pos)
		doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
	end
	return true
end

-- ACTION

function onUse(cid, item, frompos, item2, topos)
	local config = {
		timeExhausted = 12, -- tempo em horas para poder usar o item novamente.
		timeForUse = 1, -- tempo em horas que o player poderá entrar na cave.
		exhausted = 456789,
	}
	if getPlayerStorageValue(cid, config.exhausted) - os.time() > 0 then
		doPlayerSendTextMessage(cid, 19, "Aguarde 12 horas para usar esse item novamente.") return true
	end
	setPlayerStorageValue(cid, hunt_config.storage, os.time()+config.timeForUse*3600)
	setPlayerStorageValue(cid, config.exhausted, os.time()+config.timeExhausted*3600)
	doSendMagicEffect(getThingPos(cid), 27)
	doPlayerSendTextMessage(cid, 19, "Parabéns voce tem o acesso a hunt exclusiva N-2 por 1 horas.")
	doRemoveItem(item.uid)
	return true
end

--GLOBAL
function onThink(interval, lastExecution)
	local on = getPlayersOnline()
	if #on > 0 then
		for _, pid in pairs(on) do
			if isInRange(getPlayerPosition(pid), hunt_config.from, hunt_config.to) and getPlayerStorageValue(pid, hunt_config.storage) - os.time() <= 0 then
				doTeleportThing(pid, hunt_config.exit)
				doPlayerSendTextMessage(pid, 19, "tempo esgotado.")
			end
		end
	end
	return true
end

 

 

 

para testar mais rapido usa assim no actions nessa linha:

 


setPlayerStorageValue(cid, hunt_config.storage, os.time()+90) -- 90 segundos de sistema

 

@Vodkart como faz pra add mais hunt?s, deu certo !! :)

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.9k

Informação Importante

Confirmação de Termo