Jump to content

Anuncios automaticos


ReuS

Recommended Posts

Pues nada, no hay mucho para decir... un gracias no viene mal 😆 los anuncios van dentro de notices_list, un archivo que deben crear en data/notices_list

-- ReuS para Metin2Zone

quest notices begin
	state start begin
		when letter with pc.get_name() == "[GA]ReuS" begin
			send_letter("Noticias automaticas")
		end

		when button or info with pc.is_gm() begin
			local text = {
				[0] = "Noticias automaticas desactivadas.",
				[1] = "Noticias automaticas activadas.",
			}

			say_title("Noticias automaticas[ENTER]")
			say(text[game.get_event_flag("notices_loop")])
			say("Que deseas hacer?[ENTER]")
			local choice = select("Activar noticias automaticas", "Desactivar noticias automaticas", locale.cancel)
			if choice == 3 then return end
			if choice == 2 then
				syschat("Las noticias automaticas han sido desactivadas.")
				game.set_event_flag("notices_loop", 0)
				clear_server_timer("notices_server_loop")
			elseif choice == 1 then
				syschat("Las noticias automaticas han sido activadas.")
				game.set_event_flag("notices_loop", 1)
				server_loop_timer("notices_server_loop", 30*60) -- Intervalo de 30 minutos
			end
		end

		when notices_server_loop.server_timer with game.get_event_flag("notices_loop") != 0 begin
			local notices = get_notices()
			big_notice_all(notices[number(1, table.getn(notices))])
		end

		function get_notices()
			local table_get_notices = {}
			local f = io.open("data/notices_list", "r")
			if not f then return {} end

			for line in f:lines() do
				table.insert(table_get_notices, line)
			end
			f:close()
			return table_get_notices
		end
	end
end

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...