SA-MP Forums Archive
Almacenar informaciуn en un archivo .txt - 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: Almacenar informaciуn en un archivo .txt (/showthread.php?tid=530774)



Almacenar informaciуn en un archivo .txt - xTexTx - 09.08.2014

Hola, tengo ganas de aprender a como hacer para que cuando utilicen: /g [Mensaje], almacene los mensajes que envнan en un archivo .txt.
їAlguien se tomarнa las molestias de explicarme?, muchas gracias.


Re: Almacenar informaciуn en un archivo .txt - admantis - 09.08.2014

Hola amigo, puedes utilizar la funciуn fwrite. Estб muy bien documentada en la Wiki.

https://sampwiki.blast.hk/wiki/Fwrite


Respuesta: Almacenar informaciуn en un archivo .txt - Alvaro89 - 09.08.2014

No soy bueno explicando amigo. Pero como veras el codigo es de lo mas simple

Aqui imagenes que funciona

[IMG][/IMG]

[IMG][/IMG]

Codigo

PHP код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#define loghablan              "Logs/Hablan.txt"
CMD:hablar(playeridparams[])
{
    new 
texto[128];
    if(
sscanf(params"s[128]"texto)) return SendClientMessage(playerid, -1"USA:{FF0000} /hablar (texto)");
    new 
string[150], nombre[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnombresizeof(nombre));
    
format(stringsizeof(string), "%s dice: %s"nombretexto);
    
LogTest(string);
    return 
1;
}
forward LogTest(string[]);
public 
LogTest(string[])
{
   new 
entry[256];
   
format(entrysizeof(entry), "%s\r\n",string);
   new 
File:hFile;
   
hFile fopen(loghablanio_append);
   
fwrite(hFileentry);
   
fclose(hFile);




Respuesta: Almacenar informaciуn en un archivo .txt - Swedky - 09.08.2014

Quote:
Originally Posted by Alvaro89
Посмотреть сообщение
No soy bueno explicando amigo. Pero como veras el codigo es de lo mas simple

Aqui imagenes que funciona

[IMG][/IMG]

[IMG][/IMG]

Codigo

PHP код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#define loghablan              "Logs/Hablan.txt"
CMD:hablar(playeridparams[])
{
    new 
texto[128];
    if(
sscanf(params"s[128]"texto)) return SendClientMessage(playerid, -1"USA:{FF0000} /hablar (texto)");
    new 
string[150], nombre[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnombresizeof(nombre));
    
format(stringsizeof(string), "%s dice: %s"nombretexto);
    
LogTest(string);
    return 
1;
}
forward LogTest(string[]);
public 
LogTest(string[])
{
   new 
entry[256];
   
format(entrysizeof(entry), "%s\r\n",string);
   new 
File:hFile;
   
hFile fopen(loghablanio_append);
   
fwrite(hFileentry);
   
fclose(hFile);

Formateas la misma cadena 2 veces, para quй?


Respuesta: Almacenar informaciуn en un archivo .txt - DesingMyCry - 09.08.2014

A que te refieres Enzo?


Re: Almacenar informaciуn en un archivo .txt - SickAttack - 09.08.2014

Te sugiero que guardes la informaciуn en archivos nuevos con la fecha como nombre del archivo, asн podrбs disminuir el tamaсo del archivo y se abran mas rбpido.