03.12.2010, 11:16
I'm making a system that saves the day, month, year, hour, minute and ip logged to the player who signed to appear in next to him:
His last login was on 02/12/2010 at 16:15 by ip: 11111111111
It works almost 100%
the only problem is that when he logs a second time, to save over envez doque had it just continues.
I'm doing the following:
To save the data:
To read the data from last login:
What's going on is as follows:
The first login will save this:
2 | 12 | 2010 | 16 | 18 | 1111111
and will read it right
already the second will be saved like this:
2 | 12 | 2010 | 16 | 18 | 11111113 | 12 | 2010 | 15 | 11 | 1111111
One after the other.
Causes problems.
What I wanted to do is clean the file before each new bailout, or delete.
So I do not know how.
I tried deleting the file by OnPlayerDisconnect but I can not.
So I can delete the file when the player is off, then I type a cmd to delete and delete.
Can someone help me please, because I have this problem in a tempban I did too ...
sorry for my bad english
His last login was on 02/12/2010 at 16:15 by ip: 11111111111
It works almost 100%
the only problem is that when he logs a second time, to save over envez doque had it just continues.
I'm doing the following:
To save the data:
pawn Код:
new giveplayer[MAX_PLAYER_NAME];
GetPlayerName(playerid, giveplayer, sizeof(giveplayer));
new stringaa[128];
new stringgg[128];
GetPlayerIp(playerid,ip,15);
format(stringaa, sizeof(stringaa), "/LogPlayer/%s.ini", giveplayer);
if(!dini_Exists(stringaa))
{
dini_Create(stringaa);
}
new File:logadmin = fopen(stringaa, io_append);
if(logadmin)
{
new Ano, Mes,Dia;
getdate(Ano, Mes,Dia);
getdate(Anologp[playerid], Meslogp[playerid],Dialogp[playerid]);
new Hora, Minuto, Segundo;
gettime(Hora, Minuto, Segundo);
gettime(Horalogp[playerid], Minutologp[playerid], Segundologp[playerid]);
format(stringgg, sizeof stringgg, "%d|%d|%d|%d|%d|%s", Dia, Mes, Ano, Hora, Minuto,ip);
fwrite(logadmin, stringgg);
fclose(logadmin);
pawn Код:
new Baname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Baname, sizeof(Baname));
new string123[128];
format(string123, sizeof(string123), "/LogPlayer/%s.ini", Baname);
if(fexist(string123))
{
new load[12][32];
new str[128];
new UltimoDia,UltimoMes,UltimoAno,UltimaHora,UltimoMinuto,UltimoIp[15];
new File:file = fopen(string123,io_read);
if (file)
{
while (fread(file, str, sizeof str))
{
split(str, load, '|');
UltimoDia = strval(load[0]);
UltimoMes = strval(load[1]);
UltimoAno = strval(load[2]);
UltimaHora = strval(load[3]);
UltimoMinuto = strval(load[4]);
strmid(UltimoIp, load[5], 0, strlen(load[5])-1, 15);
format(str, sizeof str, "His last login was on%d/%d/%d бs %d:%d, by ip: %s",UltimoDia,UltimoMes,UltimoAno,UltimaHora,UltimoMinuto,UltimoIp);
SendClientMessage(playerid, ADMIN_RED, str);
}
}
return 1;
}]
What's going on is as follows:
The first login will save this:
2 | 12 | 2010 | 16 | 18 | 1111111
and will read it right
already the second will be saved like this:
2 | 12 | 2010 | 16 | 18 | 11111113 | 12 | 2010 | 15 | 11 | 1111111
One after the other.
Causes problems.
What I wanted to do is clean the file before each new bailout, or delete.
So I do not know how.
I tried deleting the file by OnPlayerDisconnect but I can not.
So I can delete the file when the player is off, then I type a cmd to delete and delete.
Can someone help me please, because I have this problem in a tempban I did too ...
sorry for my bad english