Ir para conteúdo
  • Cadastre-se

(Resolvido)Ajuste nesse sistema de hunt exclusiva


Ir para solução Resolvido por Vodkart,

Posts Recomendados

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

Link para o post
Compartilhar em outros sites
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.

Link para o post
Compartilhar em outros sites
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 !! :)

Link para o post
Compartilhar em outros sites
  • Solução
10 horas atrás, leozincorsair disse:

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

 

já está pronto, entra discord que te passo e ensino a instalar

vodkart_logo.png

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

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
2 horas atrás, Vodkart disse:

 

já está pronto, entra discord que te passo e ensino a instalar

enviei o pedido la

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.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo