Storing a list of int values in a file
I recently started with sourcemod and I ran into a bit of a problem with the limited file I/O available in sourcemod plugins.
I need to store several lists (basically in categories) of int values in a file and retrieve them into several arrays or a single lookup table but I don't know how I would go about doing this correctly (as in not a horrible hack). Any help getting me on the right track would be appreciated. |
Re: Storing a list of int values in a file
What are you trying to accomplish?
|
Re: Storing a list of int values in a file
I am storing a list of weapon item indexes (Separated into categories) that the plugin will trigger on. I was testing with a hardcoded lookup table.
|
Re: Storing a list of int values in a file
Quote:
Can we see some code |
Re: Storing a list of int values in a file
The plugin was created with the intent of messing with my friends, it does something to them if certain weapons are equipped.
I want to populate this table from an external file so I don't have to recompile it when I want to change something. I intend to add more to it once I have the config feature working. Code:
|
Re: Storing a list of int values in a file
Read about sorting, if you are not experienced with sorting try use bubble sort or insertion sort, if you want more efficency use merge sort.
|
Re: Storing a list of int values in a file
Quote:
|
Re: Storing a list of int values in a file
Best way in my opinion would probably be a simple KeyValues file. Consider this
KeyValues file
You can edit the file as needed, but just parse the file every time the map starts with something like this.
Code
Just be sure to male slowWeapons and removeWeapons global variables. |
Re: Storing a list of int values in a file
Completely overlooked keyvalues. Whoops. Anyways, that code was really easy to integrate into the plugin with some very minor modification and it works great. Thanks for the help.
|
Re: Storing a list of int values in a file
There isn't really a reason to not flatten out the keyvalues data if you're going to do it that way:
Code:
"root"Two separate files with one number per line can be parsed with just a ReadFileLine loop and StringToInt. |
| All times are GMT -4. The time now is 12:59. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.