[Duda]Leer archivo - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (
https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: [Duda]Leer archivo (
/showthread.php?tid=362553)
[Duda]Leer archivo -
-[R]hysi- - 24.07.2012
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
Re: [Duda]Leer archivo -
Daniel-92 - 24.07.2012
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).
Respuesta: [Duda]Leer archivo -
-[R]hysi- - 24.07.2012
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?
Respuesta: [Duda]Leer archivo -
Fluid016 - 24.07.2012
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