AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Editing txt files (https://forums.alliedmods.net/showthread.php?t=132934)

katna 07-20-2010 08:30

[Help] Editing txt files
 
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.

Bugsy 07-20-2010 08:51

Re: [Help] Editing txt files
 
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

katna 07-20-2010 09:35

Re: [Help] Editing txt files
 
wow, that was a fast respond. thank you anyway, i will try it and test it a few time :D

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" 


mottzi 07-20-2010 11:39

Re: [Help] Editing txt files
 
nvault would be much easier :)

Bugsy 07-20-2010 13:41

Re: [Help] Editing txt files
 
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.

katna 07-20-2010 15:16

Re: [Help] Editing txt files
 
ok, thank you very much. nvault isn't an option for me, nvault can't perform what i want it to do.

RedRobster 07-20-2010 16:08

Re: [Help] Editing txt files
 
o.o What are you trying to do, if you don't mind my asking?

katna 07-20-2010 16:30

Re: [Help] Editing txt files
 
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.

RedRobster 07-20-2010 16:34

Re: [Help] Editing txt files
 
Okay. Fair enough.

Bugsy 07-20-2010 18:46

Re: [Help] Editing txt files
 
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.


All times are GMT -4. The time now is 07:06.

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