Quote:
Originally Posted by HamletEagle
Let me know if you get stuck or don't understand something in the template I provided. If you want some more intuition about what it does read below:
Inside saveUserData I retrieved the steamid and then use it to index the trie/save the data inside the trie. What this does is basically create an association like steamid -> (money, frags, deaths).
Inside loadUserData, I also retrieve the steamid and query the trie, asking the following "give me the data I saved for the player with this steamid". The trie will return the money, frags and deaths that we previously saved.
If you don't want to restore frags(let's say) then simply ignore the lines that say //retrieve frags and //set frags to data[frags], or to have a more modular implementation you could assign a flag value(-1) to frags inside saveUserData and then in loadUserData only set frags if the value is != -1.
Now, about your question. It makes absolutely no difference where we create the trie. The only instance where it matters is if you needed to access the trie before plugin_init.
For example, if you were to read a configuration file with model replacements inside the trie and then you wanted to precache the models, sure, you should create the trie in plugin_precache because prechaching the models should also happen inside plugin_precache. plugin_init is called after plugin_precache, creating the trie in init would not work(because it will too late).
Basically, create the trie BEFORE you need to use it.
|
Thanks for the information!
Really helpful, and very easy to understand, your trie method worked flawlessly! Love it!
As for trying to not save certain data, that is indeed a very easy and simple method as well, I could basically add a variable and then set it to true and if its true then save -1 to user money, genius
__________________