Jump to content

[Release] Sistema de noticias vía MP


Recommended Posts

Hola chicos, os traigo un sencillo sistema de noticias que serán más cómodas para el usuario y para el staff. Este sistema lee las noticias a traves de un txt y si el usuario aún no lo ha leído le manda un mp con información.

 

Una de las ventajas de este sistema es que no hace falta ningún tipo de reload o /e, ya que lee el qf a través de un txt y solo ejecuta la función si el qf del jugador es menor.

 

Empezamos

 

Abrimos game.py:

 

Debajo de 

"mall"

ponemos

"open_notice_info"		: self.__open_notice_info,
"write_notice_info"		: self.__write_notice_info,

Luego buscamos

__InGameShop_Show(self,url):

y bajo de ese def ponemos

def __open_notice_info(self):
	self.interface.RegisterGameMasterName("<--System-->")
	self.interface.RecvWhisper("<--System-->")
		
def __write_notice_info(self,text):
	chat.AppendWhisper(chat.WHISPER_TYPE_CHAT, "<--System-->", text.replace("_", " "))

Debe quedar así:

 

 

6a2af1752188b6145fecbf668c5fce87.png

 

 

 

Vamos ahora a la parte quest

Cogemos esta quest

 

 

quest noticias begin
	state start begin
		function read_notice_line(l)
			return readline("/quest/system/noticias/noticias.txt", l)
		end
		
		when login begin
			local qf = readline("/quest/system/noticias/qf.txt", 1)
			local lineas = 0
			if tonumber(qf) > pc.getqf("noticias_ver") then
				for line in io.lines("/quest/system/noticias/noticias.txt") do lineas = lineas + 1 end
				cmdchat("open_notice_info")
				for i = 1,lineas do
					cmdchat("write_notice_info "..string.gsub(noticias.read_notice_line(i), ' ', '_'))
				end
				pc.setqf("noticias_ver", qf)
			end
		end
	end
end

 

 

Y creamos un fichero en nuestra carpeta quest llamado noticias.quest, dentro metemos la quest, guardamos y cerramos.

 

Ahora creamos una carpeta en quest llamada System, y dentro de ella otra llamada noticias. En esa carpeta creamos un archivo llamado qf.txt con un 0 dentro, y creamos otro llamado noticias.txt que puede estar en blanco.

 

¡Atención! 

Es probable que no tengáis la función readline, así que aquí os la dejo.

 

 

function readline(path, x)
    local linetable = {}
    for line in io.lines(path) do
        table.insert(linetable, line)
    end
    return linetable[x]
end 

 

 

 

Para terminar añadimos a quest_functions estas dos funciones:

readline

io.lines

 

Ya lo demás es hacer qc y reload q o reboot y ya tendréis listo esto.

 

 

Como añadir noticias.

Para añadir una nueva versión de noticias deberéis sumar 1 al qf.txt, por ejemplo si está en 11 poner 12 o si está en 0 poner 1.

 

Y en noticias.txt debéis poner cada noticia en una linea.

 

 

Así queda:

fb02ee12e81b19091cfd6f1dbea000f2.gif

Link to comment
Share on other sites

  • 4 years later...

hola muy buenos dias, esta muy bueno el systema de noticias, pero tengo un problema no logro hacerlo andar.

el systema ya me vino instalado en el file akron2, y revise los archivos para modificar y estan todos como en la guia.

te paso los archivos de la carpeta systema >> noticias

 

Debes iniciar sesión para ver el contenido del enlace en esta publicación.
Debes iniciar sesión para ver el contenido del enlace en esta publicación.

Link to comment
Share on other sites

  • 7 months later...
  • 2 months later...
  • 1 month later...
En 5/1/2021 a las 9:08, Ondra Souček dijo:

Syserr game


SYSERR: Jan  5 13:02:02 :: RunState: LUA_ERROR: locale/germany/quest/questlib.lua:1907: bad argument #1 to `lines' (No such file or directory)
SYSERR: Jan  5 13:02:02 :: WriteRunningStateToSyserr: LUA_ERROR: quest noticias.start click

 

Yo subi uno completo buscalo, estos subem todo con falla 

Link to comment
Share on other sites

En 5/1/2021 a las 9:08, Ondra Souček dijo:

Syserr game


SYSERR: Jan  5 13:02:02 :: RunState: LUA_ERROR: locale/germany/quest/questlib.lua:1907: bad argument #1 to `lines' (No such file or directory)
SYSERR: Jan  5 13:02:02 :: WriteRunningStateToSyserr: LUA_ERROR: quest noticias.start click

 

Yo subi uno completo buscalo, estos subem todo con falla 

 

 

Debes iniciar sesión para ver el contenido del enlace en esta publicación.

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