03.12.2010, 13:07
Here, now the saving and the loading of data are perfectly
Saving (I did in OnPlayerDisconnect):
And Loading (i did in OnPlayerSpawn):
I want that i have helped
Saving (I did in OnPlayerDisconnect):
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new giveplayer[MAX_PLAYER_NAME];
new Anologp[MAX_PLAYERS];
new Meslogp[MAX_PLAYERS];
new Dialogp[MAX_PLAYERS];
new Horalogp[MAX_PLAYERS];
new Minutologp[MAX_PLAYERS];
new Segundologp[MAX_PLAYERS];
new Ano, Mes,Dia;
new Hora, Minuto, Segundo;
new ip[128];
new stringaa[128];
new stringgg[128];
new stringbb[128];
GetPlayerName(playerid, giveplayer, sizeof(giveplayer));
GetPlayerIp(playerid,ip,15);
format(stringaa, sizeof(stringaa), "/LogPlayer/%s.ini", giveplayer);
if(fexist(stringaa))
{
fremove(stringaa);
if (fexist(stringaa)) return false;
new File:specialvar;
specialvar=fopen(stringaa,io_write);
if (specialvar) {
getdate(Ano, Mes,Dia);
getdate(Anologp[playerid], Meslogp[playerid],Dialogp[playerid]);
gettime(Hora, Minuto, Segundo);
gettime(Horalogp[playerid], Minutologp[playerid], Segundologp[playerid]);
new File:gogo = fopen(stringaa, io_append);
format(stringbb, sizeof(stringbb), "%d|%d|%d|%d|%d|%s", Dia, Mes, Ano, Hora, Minuto, ip);
fwrite(gogo, stringbb);
fclose(gogo);
fclose(specialvar);
return true;
}
return false;
}
else
{
getdate(Ano, Mes,Dia);
getdate(Anologp[playerid], Meslogp[playerid],Dialogp[playerid]);
gettime(Hora, Minuto, Segundo);
gettime(Horalogp[playerid], Minutologp[playerid], Segundologp[playerid]);
new File:logadmin = fopen(stringaa, io_append);
format(stringgg, sizeof(stringgg), "%d|%d|%d|%d|%d|%s", Dia, Mes, Ano, Hora, Minuto, ip);
fwrite(logadmin, stringgg);
fclose(logadmin);
return 1;
}
}
And Loading (i did in OnPlayerSpawn):
pawn Код:
public OnPlayerSpawn(playerid)
{
new nicklogger[MAX_PLAYER_NAME];
GetPlayerName(playerid, nicklogger, sizeof(nicklogger));
new stringlogging[128];
format(stringlogging, sizeof(stringlogging), "/LogPlayer/%s.ini", nicklogger);
if(fexist(stringlogging))
{
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);
}
}
}
}
}
I want that i have helped