Raised This Month: $ Target: $400
 0% 

[Help] Editing txt files


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
katna
Senior Member
Join Date: May 2010
Old 07-20-2010 , 08:30   [Help] Editing txt files
Reply With Quote #1

well i'm creating a plugin which save the top 5 only scorers(soccerjam) in a txt file in this format:
PHP Code:
"Steam id" "Goals" "Assist" 
any way i coded it and got it to be like this
PHP Code:
"STEAM_0:1:31287965" 0 0
"STEAM_0:1:23423345" 0 0 
now the problem is how can i edit the goal amount or the assist amount.
do i need to delete this line and re-add it edited or there is a better way to do it? for example if someone score and he is one of the top 5. Automaticly update the txt where is steamid.
katna is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-20-2010 , 08:51   Re: [Help] Editing txt files
Reply With Quote #2

You can either replace an entire line or just overwrite the data/# being updated. Easiest would be replacing the entire line IMO. Why not use nvault?

You can take a look here http://forums.alliedmods.net/showthread.php?t=104681
__________________
Bugsy is offline
katna
Senior Member
Join Date: May 2010
Old 07-20-2010 , 09:35   Re: [Help] Editing txt files
Reply With Quote #3

wow, that was a fast respond. thank you anyway, i will try it and test it a few time

edit: if i have a textfile like this:
PHP Code:
"Old Text" 
and im using
PHP Code:
write_file(file_name,"New Text",0); 
will it change the file to :
PHP Code:
"New Text" 

Last edited by katna; 07-20-2010 at 09:49.
katna is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-20-2010 , 11:39   Re: [Help] Editing txt files
Reply With Quote #4

nvault would be much easier
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-20-2010 , 13:41   Re: [Help] Editing txt files
Reply With Quote #5

Yes, the third param specifies which line the data is written to; it will overwrite old data if data exists. Im not sure off the top of my head if line 1 is referenced with 0 or 1. Use -1 to append the line to the end of file. Just use nvault unless you need to manually edit this file with notepad or w/e.
__________________

Last edited by Bugsy; 07-20-2010 at 13:47.
Bugsy is offline
katna
Senior Member
Join Date: May 2010
Old 07-20-2010 , 15:16   Re: [Help] Editing txt files
Reply With Quote #6

ok, thank you very much. nvault isn't an option for me, nvault can't perform what i want it to do.
katna is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 07-20-2010 , 16:08   Re: [Help] Editing txt files
Reply With Quote #7

o.o What are you trying to do, if you don't mind my asking?
RedRobster is offline
katna
Senior Member
Join Date: May 2010
Old 07-20-2010 , 16:30   Re: [Help] Editing txt files
Reply With Quote #8

i will tell you, i solved it anyway. I'm trying to get the top5 scores(soccerjam server) and update their goals life time. I don't want to use nvault, i have my reasons.
katna is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 07-20-2010 , 16:34   Re: [Help] Editing txt files
Reply With Quote #9

Okay. Fair enough.
RedRobster is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-20-2010 , 18:46   Re: [Help] Editing txt files
Reply With Quote #10

If you don't want to use nvault because of preference just say so. If you have valid reasons not to use it I am interested why.
__________________
Bugsy is offline
Reply


Thread Tools
Display Modes

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 07:06.


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