Text File Handling
I made this code to store and read the previous ten maps in text files. And push them to an adt array.
But now I want to store thirty maps in a text file and this method is horribly crude. Is there a better way to accomplish this task, like to store the content in one text file? The last time I tried writing to a different line, it went horrible with 100's of spacers between lines. :( PHP Code:
|
Re: Text File Handling
why don't just
PHP Code:
UPD or try this, but there contains more then 10 last maps PHP Code:
|
Re: Text File Handling
Quote:
Quote:
|
Re: Text File Handling
stickz, with LogToFileEx:
Quote:
Quote:
Quote:
It's CVar, not command. |
Re: Text File Handling
LogToFileEx isn't a good solution because I need to read each map name, then add it to an ADT Array. It adds tons of date/time junk to the file, that will need to be parsed through. There's got to be a better way to do this, that writes ONLY the map name and nothing else to a text file.
I was looking into JSON strings awhile back, but there are no good wrappers or documentation to work with these; that are easy to understand and implement. |
Re: Text File Handling
Make sure that the line(s) you read or write don't have any unnecessary new line characters by using TrimString on them. This will fix your "spacer" problem and you can use a single file. GetMapHistory might be useful too.
|
Re: Text File Handling
Quote:
My final working code: PHP Code:
|
Re: Text File Handling
I would actually trim it before pushing it into the array and only push it when it's not empty by then.
|
Re: Text File Handling
In my opinion, this kind of plugin is best servers via a database, even if sqlite. You could store as many as you want, and change the number saved at any time via a cvar. This solution would also allow you to track the most played maps, etc. There are quite a few plugins that do this already...perhaps if you are running one of those, you could instead have your plugin query that database.
|
All times are GMT -4. The time now is 23:42. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.