Tamaño del Texto:
Bienvenido(a), Visitante. Por favor, ingresa o regístrate.
¿Perdiste tu email de activación?
 

Páginas: [1]   Ir Abajo
  Imprimir  
Autor Tema: Información Players Online Servers TXT  (Leído 62 veces)
0 Usuarios y 1 Visitante están viendo este tema.
Dolbar
Posteador Habitual
***

Reputacion: 10
Desconectado Desconectado

Sexo: Masculino
Mensajes: 136
Miembro Nº: 2842





Última visita: 06 de Octubre de 2008, 09:36:37

- ¡Lee las Normas por favor. Utiliza siempre el Buscador y Titulos correctos en tus post! -
« : 19 de Mayo de 2008, 09:01:56 »

MM no se si esto vaya aquí, no supe donde ponerlo  psickhy2

Bueno, pues hace poco vi un pequeño script php que puso knzo en la seccion de dudas y sugerencias respondiendo a la pregunta de otro miembro del foro, sobre como desplegar una lista de usuarios online en una pagina web de un servidor TXT.

http://www.foro.divinero.net/dudas-y-sugerencias/mostrar-users-online-en-txt-t12734.0.html (he aquí el topic)

pues me puse a buscar si había alguna forma de mostrar más información ya que con mi emulador sólo podía ver el nombre de los chars que estuvieran online y encontré lo siguiente en el archivo (la verdad no se porque no lo había visto  pcontej2)char_eathena.conf:

Código:
//NOTE: The following online listing options are only for TXT servers.

// Filename of the file which receives the online players list in text
online_txt_filename: online.txt

// Filename of the file which receives the online players list, but in html version
online_html_filename: online.html

// Choose how to display online players.
// (sorting operation with a lot of online players can take time on a slow computer)
// 0: no sorting (default)
// 1: by alphabetical order of their name
// 2: by number of their zenys
// 3: by their base level
// 4: by their job (and job level inside the same job)
// 5: by alphabetical order of their actual map location
online_sorting_option: 1

// Choose which columns that you want display in the online files. Do the addition of these values:
// (if value is 0, no file is done)
// 1: name (just the name, no function like 'GM')
// 2: job
// 4: levels
// 8: map name
// 16: mapname and coordonates
// 32: zenys
// 64: name (with 'GM' if the player is a GM)
// default value: 1 (only name)
online_display_option: 1

entonces... en la primera parte se refiere a como desplegar la lista de jugadores, o sea en que orden se monstrarán en el archivo

Código:
// 0: sin orden (default)
// 1: por orden alfabético de nombre
// 2: por el numero de zenys
// 3: por el base lvl
// 4: por job (y job lvl dentro del mismo job)
// 5: por orden alfabético  del mapa en el que se encuentran

la segunda a que tanta información será desplegada

Código:
// 1: nombre (sin 'GM' si el player tiene cuenta de GM)
// 2: job
// 4: nivel
// 8: nombre del mapa
// 16: coordenadas del mapa
// 32: zenys
// 64: nombre (con 'GM' si el player es un GM)

a partir de esto el eAthena crea 2 archivos uno txt y otro html en donde se guarda toda esta información, la que posteriormente puede ser llamada mediante php.

Para los usuarios que quieren dar formato a el archivo html directamente desde el source...

Me dió curiosidad el saber como era que el eathena generaba esos archivos debido a que estos se actualizaban cada cierto tiempo y pues no sabia como darles un formato ya que si lo hacía se borraban y se generaba un nuevo con información actualizada y sin el formato que yo le hubiese dado, y encontre esa información en el source del emulador, en el archivo char.c

Código:
// online players by [Yor]
char online_txt_filename[1024] = "online.txt";
char online_html_filename[1024] = "online.html";
int online_sorting_option = 0; // sorting option to display online players in online files
int online_display_option = 1; // display options: to know which columns must be displayed
int online_refresh_html = 20; // refresh time (in sec) of the html file in the explorer
int online_gm_display_min_level = 20; // minimum GM level to display 'GM' when we want to display it

y más adelante en el mismo archivo está lo siguiente:

Código:
//-------------------------------------------------------------
// Function to create the online files (txt and html). by [Yor]
//-------------------------------------------------------------
void create_online_files(void)
{
unsigned int k, j; // for loop with strlen comparing
int i, l; // for loops
int players;    // count the number of players
FILE *fp;       // for the txt file
FILE *fp2;      // for the html file
char temp[256];      // to prepare what we must display
time_t time_server;  // for number of seconds
struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
int id[4096];

if (online_display_option == 0) // we display nothing, so return
return;

// Get number of online players, id of each online players, and verify if a server is offline
players = 0;
online_char_db->foreach(online_char_db, create_online_files_sub, &players, &id);

// write files
fp = fopen(online_txt_filename, "w");
if (fp != NULL) {
fp2 = fopen(online_html_filename, "w");
if (fp2 != NULL) {
// get time
time(&time_server); // get time in seconds since 1/1/1970
datetime = localtime(&time_server); // convert seconds in structure
strftime(temp, sizeof(temp), "%d %b %Y %X", datetime); // like sprintf, but only for date/time (05 dec 2003 15:12:52)
// write heading
fprintf(fp2, "<HTML>\n");
fprintf(fp2, "  <META http-equiv=\"Refresh\" content=\"%d\">\n", online_refresh_html); // update on client explorer every x seconds
fprintf(fp2, "  <HEAD>\n");
fprintf(fp2, "    <TITLE>Online Players on %s</TITLE>\n", server_name);
fprintf(fp2, "  </HEAD>\n");
fprintf(fp2, "  <BODY>\n");
fprintf(fp2, "    <H3>Online Players on %s (%s):</H3>\n", server_name, temp);
fprintf(fp, "Online Players on %s (%s):\n", server_name, temp);
fprintf(fp, "\n");

for (i = 0; i < players; i++) {
// if it's the first player
if (i == 0) {
j = 0; // count the number of characters for the txt version and to set the separate line
fprintf(fp2, "    <table border=\"1\" cellspacing=\"1\">\n");
fprintf(fp2, "      <tr>\n");
if ((online_display_option & 1) || (online_display_option & 64)) {
fprintf(fp2, "        <td><b>Name</b></td>\n");
if (online_display_option & 64) {
fprintf(fp, "Name                          "); // 30
j += 30;
} else {
fprintf(fp, "Name                     "); // 25
j += 25;
}
}
if ((online_display_option & 6) == 6) {
fprintf(fp2, "        <td><b>Job (levels)</b></td>\n");
fprintf(fp, "Job                 Levels "); // 27
j += 27;
} else if (online_display_option & 2) {
fprintf(fp2, "        <td><b>Job</b></td>\n");
fprintf(fp, "Job                "); // 19
j += 19;
} else if (online_display_option & 4) {
fprintf(fp2, "        <td><b>Levels</b></td>\n");
fprintf(fp, " Levels "); // 8
j += 8;
}
if (online_display_option & 24) { // 8 or 16
fprintf(fp2, "        <td><b>Location</b></td>\n");
if (online_display_option & 16) {
fprintf(fp, "Location     ( x , y ) "); // 23
j += 23;
} else {
fprintf(fp, "Location     "); // 13
j += 13;
}
}
if (online_display_option & 32) {
fprintf(fp2, "        <td ALIGN=CENTER><b>zenys</b></td>\n");
fprintf(fp, "          Zenys "); // 16
j += 16;
}
fprintf(fp2, "      </tr>\n");
fprintf(fp, "\n");
for (k = 0; k < j; k++)
fprintf(fp, "-");
fprintf(fp, "\n");
}
fprintf(fp2, "      <tr>\n");
// get id of the character (more speed)
j = id[i];
// displaying the character name
if ((online_display_option & 1) || (online_display_option & 64)) { // without/with 'GM' display
strcpy(temp, char_dat[j].status.name);
l = isGM(char_dat[j].status.account_id);
if (online_display_option & 64) {
if (l >= online_gm_display_min_level)
fprintf(fp, "%-24s (GM) ", temp);
else
fprintf(fp, "%-24s      ", temp);
} else
fprintf(fp, "%-24s ", temp);
// name of the character in the html (no < >, because that create problem in html code)
fprintf(fp2, "        <td>");
if ((online_display_option & 64) && l >= online_gm_display_min_level)
fprintf(fp2, "<b>");
for (k = 0; k < strlen(temp); k++) {
switch(temp[k]) {
case '<': // <
fprintf(fp2, "&lt;");
break;
case '>': // >
fprintf(fp2, "&gt;");
break;
default:
fprintf(fp2, "%c", temp[k]);
break;
};
}
if ((online_display_option & 64) && l >= online_gm_display_min_level)
fprintf(fp2, "</b> (GM)");
fprintf(fp2, "</td>\n");
}
// displaying of the job
if (online_display_option & 6) {
char * jobname = job_name(char_dat[j].status.class_);
if ((online_display_option & 6) == 6) {
fprintf(fp2, "        <td>%s %d/%d</td>\n", jobname, char_dat[j].status.base_level, char_dat[j].status.job_level);
fprintf(fp, "%-18s %3d/%3d ", jobname, char_dat[j].status.base_level, char_dat[j].status.job_level);
} else if (online_display_option & 2) {
fprintf(fp2, "        <td>%s</td>\n", jobname);
fprintf(fp, "%-18s ", jobname);
} else if (online_display_option & 4) {
fprintf(fp2, "        <td>%d/%d</td>\n", char_dat[j].status.base_level, char_dat[j].status.job_level);
fprintf(fp, "%3d/%3d ", char_dat[j].status.base_level, char_dat[j].status.job_level);
}
}
// displaying of the map
if (online_display_option & 24) { // 8 or 16
// prepare map name
memcpy(temp, mapindex_id2name(char_dat[j].status.last_point.map), MAP_NAME_LENGTH);
// write map name
if (online_display_option & 16) { // map-name AND coordinates
fprintf(fp2, "        <td>%s (%d, %d)</td>\n", temp, char_dat[j].status.last_point.x, char_dat[j].status.last_point.y);
fprintf(fp, "%-12s (%3d,%3d) ", temp, char_dat[j].status.last_point.x, char_dat[j].status.last_point.y);
} else {
fprintf(fp2, "        <td>%s</td>\n", temp);
fprintf(fp, "%-12s ", temp);
}
}
// displaying nimber of zenys
if (online_display_option & 32) {
// write number of zenys
if (char_dat[j].status.zeny == 0) { // if no zeny
fprintf(fp2, "        <td ALIGN=RIGHT>no zeny</td>\n");
fprintf(fp, "        no zeny ");
} else {
fprintf(fp2, "        <td ALIGN=RIGHT>%d z</td>\n", char_dat[j].status.zeny);
fprintf(fp, "%13d z ", char_dat[j].status.zeny);
}
}
fprintf(fp, "\n");
fprintf(fp2, "      </tr>\n");
}
// If we display at least 1 player
if (players > 0) {
fprintf(fp2, "    </table>\n");
fprintf(fp, "\n");
}

// Displaying number of online players
if (players == 0) {
fprintf(fp2, "    <p>No user is online.</p>\n");
fprintf(fp, "No user is online.\n");
} else if (players == 1) {
fprintf(fp2, "    <p>%d user is online.</p>\n", players);
fprintf(fp, "%d user is online.\n", players);
} else {
fprintf(fp2, "    <p>%d users are online.</p>\n", players);
fprintf(fp, "%d users are online.\n", players);
}
fprintf(fp2, "  </BODY>\n");
fprintf(fp2, "</HTML>\n");
fclose(fp2);
}
fclose(fp);
}

return;
}

donde hay que resaltar las lineas similares a éstas:

Código:
fprintf(fp2, "<HTML>\n");
fprintf(fp2, "  <META http-equiv=\"Refresh\" content=\"%d\">\n", online_refresh_html); // update on client explorer every x seconds
fprintf(fp2, "  <HEAD>\n");
fprintf(fp2, "    <TITLE>Online Players on %s</TITLE>\n", server_name);
fprintf(fp2, "  </HEAD>\n");
fprintf(fp2, "  <BODY>\n");
fprintf(fp2, "    <H3>Online Players on %s (%s):</H3>\n", server_name, temp);
fprintf(fp, "Online Players on %s (%s):\n", server_name, temp);
fprintf(fp, "\n");

donde se puede apreciar la aparición del codigo html,  y donde fp2 y fp se refieren a los archivos online.html y online.txt respectivamente entonces aquí es donde podemos alterar la creacion del archivo html  psmileha6. y claro despues a compilar  plaughgs5

Supongo que debe existir alguna forma de extraer la información del html mediante php, para despues darle formato y que se vea más presentable online, pero verdaderamente no conozco como se use ese lenguaje  plaughgs5 así que mejor lo busqué desde el source para modificar directamente el html.

Espero que le sirva a alguien, por lo menos a mi sí  plaughgs5
En línea



DivineRO :: Foro :: Ragnarok Online
« : 19 de Mayo de 2008, 09:01:56 »

 En línea
Zealotus
Moderador
Posteador Adamantium
*

Reputacion: 872
Desconectado Desconectado

Sexo: Masculino
Mensajes: 1993
Miembro Nº: 6293


Usa el buscador antes de pedir ayuda!


WWW

Última visita: 10 de Octubre de 2008, 11:27:30

- ¡Lee las Normas por favor. Utiliza siempre el Buscador y Titulos correctos en tus post! -
« Respuesta #1 : 19 de Mayo de 2008, 09:16:04 »

Mmmm!! Muchisimas gracias!! ^^ Que amable! Me facilitastes unas cosillas^^ Lo que pasa esque no se como hacer que los demas me vean los users online! Si peudes responderme a esto....


Gracias muy util!^^
En línea






www.zerlotusro.es hosteado por trenX!
Dolbar
Posteador Habitual
***

Reputacion: 10
Desconectado Desconectado

Sexo: Masculino
Mensajes: 136
Miembro Nº: 2842





Última visita: 06 de Octubre de 2008, 09:36:37

- ¡Lee las Normas por favor. Utiliza siempre el Buscador y Titulos correctos en tus post! -
« Respuesta #2 : 19 de Mayo de 2008, 10:02:17 »

pues yo precisamente implementé el codigo php que posteo knzo en otro topic (el link que aparece arriba),

Código:
                                     <?php
$archivo="ruta al archivo\online.html";
$handle =fopen ($archivo,"r");
$contents '';
while (!feof($handle)) {
$contents .= fread($handlefilesize($archivo));
}
echo  str_replace("\n\r""
"
$contents);
?>

y con eso las personas que entran a la web de mi servidor casero, pueden ver la cantidad de users online, obviamente se necesita que tu web hosting soporte php, yo lo tengo en mi casa todo gracias al wamp server  plaughgs5 servidor apache,  php, mysql, etc.

aqui dejo una screen shot que le pedí a un amigo que tomara para comprobar que la información pudiera ser vista desde un pc remoto.
En línea



Páginas: [1]   Ir Arriba
  Imprimir  
 
Ir a:  

Powered by SMF 1.1.6 | SMF © 2006, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks

BlueSkies design by Bloc, editado por eves para DivineRO | XHTML | CSS

Página creada en 0.177 segundos con 20 consultas.


Google visitó por ultima vez esta pagina 09 de Octubre de 2008, 08:08:39