Raised This Month: $51 Target: $400
 12% 

write_file record by order top -> down in log.txt ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rx1983
Senior Member
Join Date: Jan 2009
Location: BRASIL
Old 11-23-2011 , 17:00   write_file record by order top -> down in log.txt ?
Reply With Quote #1

exemple:
PHP Code:
new diretorio[128] = "addons/amxmodx/foda/foda.html"

new frase_formatada[300] ;
formatex(frase_formatada299"%s" name);
write_filediretoriofrase_formatada); 
I created a plugin that generates a log file, however it will record from the top down, which will hinder me a lot ...
I wonder if there is any possibility of bottom-up,
where the last event to stay on top of the file.
and the last at the bottom.

is there any command for this, or some other way to make "write_file" work well.
__________________
rx1983 is offline
Send a message via MSN to rx1983
fmcTheKing
Member
Join Date: Feb 2011
Location: Brazil
Old 11-23-2011 , 19:35   Re: write_file record by order top -> down in log.txt ?
Reply With Quote #2

"foda" só podia ser brasileiro duadasiudasuidsahd
fmcTheKing is offline
Send a message via MSN to fmcTheKing Send a message via Skype™ to fmcTheKing
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 11-23-2011 , 20:22   Re: write_file record by order top -> down in log.txt ?
Reply With Quote #3

Use the new file natives to write a temp file with your "last event", and then copy the data from the old file. Delete the old file and rename the temp file to the file name.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-24-2011 , 01:08   Re: write_file record by order top -> down in log.txt ?
Reply With Quote #4

I thought write_file was able to to it, but it seems that the written line replaces the old one so you can't insert a new line without deleting the old one if the old one exists.
Weird the the old line is stored in "buffor" for nothing, unless i've missed something.

Code:
		if (i == iLine)
		{
			fgets(buffor, 2047, pFile);
			fputs(sText, pTemp);
			fputc('\n', pTemp);
		}
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
rx1983
Senior Member
Join Date: Jan 2009
Location: BRASIL
Old 11-24-2011 , 09:20   Re: write_file record by order top -> down in log.txt ?
Reply With Quote #5

which is beyond my understanding you can get.
I will continue studying in order to understand these codes.
__________________
rx1983 is offline
Send a message via MSN to rx1983
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 11-24-2011 , 09:50   Re: write_file record by order top -> down in log.txt ?
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
I thought write_file was able to to it, but it seems that the written line replaces the old one so you can't insert a new line without deleting the old one if the old one exists.
Weird the the old line is stored in "buffor" for nothing, unless i've missed something.

Code:
		if (i == iLine)
		{
			fgets(buffor, 2047, pFile);
			fputs(sText, pTemp);
			fputc('\n', pTemp);
		}
Wouldn't you have to put the original line back?

You get the original line, you replace it with the line you want, and add a new line character at the end of the line, but I don't see anywhere you putting the new line back. Maybe that's why buffor is never used?
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-24-2011 , 12:13   Re: write_file record by order top -> down in log.txt ?
Reply With Quote #7

I meant that if i understand correctly how the native works, when you specify a line, if that line already exists, in that case the line is replaced with the one you write, and old line is just erased, and buffer in that situation is filled with old line but not rewritten, so you can replace a line but you can't insert a line.
If you could do so you would only have to write the line 0 and it would be perfect.
I'm affraid you only have as solution the way Emp gave.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:20.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode