19.01.2010, 16:25
Hello,
i have one thing to do but i not know how.Okay...
1.What i need to do?
-I need to get last 10 lines from one .txt file.
2.How much lines have in that .txt file?
- They are dynamic ca be 10 or 10000.
3.For what i need to do that?
- I work on one report system witch saves all reports in one .txt file.
4.Any special thing for that?
- I need to make one command /lastreports or something like that and to show last 10 reports from all users.
They do /report nanana... 10 times i need to get 10 times nanana..About the name of .txt i can change it just give sample with report.txt
Thanks for help all are wellcome.
Hello its me again :P,
Okay i made one command but i have something like error.
1.What kind of error?
-Okay in pawn everything is good no error no warning.But in game i write the command /lastreports and nothing happens 30 seconds after i write the command server shutting down.
2.Where is the command?
-
3.What you want to do?
- Just look for errors because i thing have some...
i have one thing to do but i not know how.Okay...
1.What i need to do?
-I need to get last 10 lines from one .txt file.
2.How much lines have in that .txt file?
- They are dynamic ca be 10 or 10000.
3.For what i need to do that?
- I work on one report system witch saves all reports in one .txt file.
4.Any special thing for that?
- I need to make one command /lastreports or something like that and to show last 10 reports from all users.
They do /report nanana... 10 times i need to get 10 times nanana..About the name of .txt i can change it just give sample with report.txt
Thanks for help all are wellcome.
Hello its me again :P,
Okay i made one command but i have something like error.
1.What kind of error?
-Okay in pawn everything is good no error no warning.But in game i write the command /lastreports and nothing happens 30 seconds after i write the command server shutting down.
2.Where is the command?
-
pawn Код:
if(strcmp(cmd, "/lastreports", true) == 0)
{
new lines;
new File:zeport = fopen("/Log/zeport.log", io_read);
while(fread(zeport, str))////..
{
lines++;
}
printf("File has %d lines");
new max_lines = lines;
lines = 0;
while(lines < max_lines - 10)
{
fread(zeport, str); //moving the pointer a line down until its on the 10th line from the back
lines++;
}
while(max_lines >= lines)
{
fread(zeport, str); //reading the last 10 lines
format(str, sizeof(string), "Last 10 reports: %d", lines);
SendClientMessage(playerid, COLOR_RED, str);
printf("Reading line %d", lines);
lines++;
}
fclose(zeport);
return 1;
}
3.What you want to do?
- Just look for errors because i thing have some...