[HELP] Save Model Permanent
I made a plugin in which players write /skins and you can buy your skins.
The problem is i dont know how can set this skin (forever). Maybe set skin by steam id no? Example code: Code:
|
Re: [HELP] Save Model Permanent
Just an example to save and load your weapon. I use fvault
PHP Code:
|
Re: [HELP] Save Model Permanent
DavidJr so i need to add more weapons here right?
Code:
I'm getting tag mismatch error: Code:
|
Re: [HELP] Save Model Permanent
Quote:
Example 1: STEAM_ID_BLAH_AWP 1 STEAM_ID_BLAH_M4A1 4 STEAM_ID_BLAH_AK47 2 Example 2: STEAM_ID_BLAH 1,4,2 The first example will create a larger vault but it will be more efficient while saving/loading single values. The second example will also be harder to edit if you start adding or removing weapons. You are locked to that structure and you can't remove values even if they're not being used anymore. Not sure which one is more efficient while loading all values. Probably the second one. "_Wpn" suffix is completely useless and will only add to the native calls. If you're only using the vault for true/false values you can make it a bitsum for up to 31 (or 32, I'm not sure) weapons in one value. You also can make it a "binary" string for several values. "100101", much like the second example. Quote:
Code:
|
Re: [HELP] Save Model Permanent
Black Rose i want to use method 2.
The "binary" is too much to me :P I've putted this(below) and works. How can i remove if the player change the usp model? (set g_HasuspP false again) Code:
To save multiple guns how can i made? Code:
|
Re: [HELP] Save Model Permanent
This will display the differences between loading and parsing data from various vault systems and methods.
Code:
The first example looks good and is made for storing integers the way they were intended to. The second example is not only horrible looking but it's wasteful of those precious resources. The more you add to it, the worse it will be. The third example is basically like the first one. So which one should we pick? It depends. We could use example 1 with a bitsum and bitmasking to set 31 variables to true/false. But that would not look very good. Code:
Both bitsum options are generally very bad as permanent storage. It will create a problem because you can not add more than 31 weapons. You also can't remove old ones to make room for new ones because that would corrupt the vault data. Instead it would be better to use example 1 or 3 with an "array" and possibly an enumeration index for readability. That way you have no limit on the vault size, minimizing native calls and also the code space, downside is higher memory usage. Memory is cheap and won't affect the performance of the server as much as CPU hungry solutions. So here's the save & load I would suggest. Code:
This however requires you to remake the weapon variables. When you want to give someone a weapon you use the array + index. Code:
Code:
Code:
There's a reason for using 1 and -1 instead of 1 and 0. Since the data is saved as a string 0 would terminate the string. Here's an example with the code you supplied: Code:
I'm sorry for complicating it further but in the end this would make the whole code easier to work with in general. You still need to understand how it works so you can make changes yourself, so if you have any questions just ask. |
Re: [HELP] Save Model Permanent
Black Rose thank you very much :D
All works good. In file_vault/skins.txt i have: (XXXXX is to ommit my id) "STEAM_0:0:XXXXX" "ÿÿÿÿÿÿÿÿÿÿÿÿ" 1395261491 Is not possible define GoldenDeagle to number 1 and GoldenAK to number 2? "STEAM_0:0:XXXXX" "1, 2" |
Re: [HELP] Save Model Permanent
I avoided using commas, whitespace and ASCII encoding as that would require parse() and an edit of the save/load function every time you add or remove a weapon. It would also increase the filesize.
You could do this: Code:
If you could explain what you mean and why you want it I will try helping you. |
Re: [HELP] Save Model Permanent
Cause this is a mess :P But works and is the most important.
So what you recommend? Code:
Code:
|
Re: [HELP] Save Model Permanent
What's the mess? You're not supposed to read the vault as a book.
The first one is one less memory call for the variable value, so that would be more efficient. But that's really not a concern here so it really makes no difference whatsoever. I would consider the second one messier because you would have to make the if statements look the same. In the end you are the author of your plugin and you decide which method you want to use. You are the one who are going to maintain it. I'll show you a "cleaner" way tomorrow. |
| All times are GMT -4. The time now is 05:54. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.