[Duda]Leer archivo
#1

Tengo una duda,quiero leer el contenido de un archivo(log).Se que se puede(o eso creo)

osea..

De esta forma se puede escribir..
pawn Код:
function KickLog(string[])
{
new entry[256];
format(entry, sizeof(entry), "%s\r\n",string);
new File:hFile;
hFile = fopen("Logs/kick.log", io_append);
fwrite(hFile, entry);
fclose(hFile);
}
//despues

format(string, sizeof(string), "[Atenciуn]: %s Fue kickeado por %s, razon: %s (%d-%d-%d)",NombreJugador(params[0]),NombreJugador(playerid),params[1],day,month,year);
KickLog(string);
Bueno yo quiero leer eso que se guarda en el log desde el servidor.

Por ejemplo el comando /hola y que me muestre el contenido del archivo

Hay alguna manera?

Desde ya muchas gracias
Reply
#2

pawn Код:
new File:file = fopen("Archivo.txt",io_read);
new string[768],result[128];
if(file) {
    while(fread(file,result)) {
        strcat(string,result);
    }
}
ShowPlayerDialog(playerid,100,DIALOG_STYLE_MSGBOX,"Contenido",string,"Aceptar","");
Esto te mostraria todo el archivo (siempre que no se pase de 768 caracteres).
Reply
#3

No me funciona :S

pawn Код:
YCMD:verhack(playerid, params[], help)
{
if (help) SendClientMessage(playerid, 0xFF0000AA, "Para ver el log"); //ayuda y_ini
else
{
if (Informacion[playerid][pAdmin] < 10) return SendClientMessage(playerid, COLOR_GRAD2, "ЎNo autorizado!");
new File:file = fopen("AntiAdminHack.log",io_read);
new string[768],result[128];
if(file) {
while(fread(file,result)) {
strcat(string,result);
}
}
ShowPlayerDialog(playerid,LOG,DIALOG_STYLE_MSGBOX,"Contenido",string,"Aceptar","");
return 1;
}
return 1;
}
Pongo el comando y nada sucede osea no aparece ni siquiera el dialog u.u

PD:hay alguna manera de vaciar el archivo o borrarlo tambiйn?
Reply
#4

Quote:
Originally Posted by -[R]hysi-
Посмотреть сообщение
No me funciona :S

pawn Код:
YCMD:verhack(playerid, params[], help)
{
if (help) SendClientMessage(playerid, 0xFF0000AA, "Para ver el log"); //ayuda y_ini
else
{
if (Informacion[playerid][pAdmin] < 10) return SendClientMessage(playerid, COLOR_GRAD2, "ЎNo autorizado!");
new File:file = fopen("AntiAdminHack.log",io_read);
new string[768],result[128];
if(file) {
while(fread(file,result)) {
strcat(string,result);
}
}
ShowPlayerDialog(playerid,LOG,DIALOG_STYLE_MSGBOX,"Contenido",string,"Aceptar","");
return 1;
}
return 1;
}
PD:hay alguna manera de vaciar el archivo o borrarlo tambiйn?
Si usa Fremove
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)