Raised This Month: $60 Target: $400
 15% 

[INC] nVault Array


Post New Thread Reply   
 
Thread Tools Display Modes
aEEk
Member
Join Date: May 2012
Location: Romania
Old 05-29-2020 , 16:19   Re: [INC] nVault Array
Reply With Quote #11

Quote:
Originally Posted by Bugsy View Post
I guess, but it looks sloppy being inconsistent.


I think you did the complete opposite. It's much more uniform to have an enumerator define all of your constants instead of having multiple arrays floating around in your code, and indexed inconsistently var[id][i] and var[i][id]. It's easy to mess something up with code like this since you may forget how you are indexing an array and may assign a value with var[id][i] when you declared the array for var[i][id] use.

It looks like you are saving a ton of data for each player and this can likely be reduced. Can you explain what this is for?

PHP Code:
// LOAD STATTRAK SKINS to USER ID
formatex(szKeycharsmax(szKey), "%s-STTK"auth);

if(
nvault_get_array(vault_stattrak_idszKeyuserSTATTRAK[id][ePlayerStattrak:0], sizeof(userSTATTRAK[])))
{        
    for(new 
1100i++)
    {
        
stattrak[i][id]     = userSTATTRAK[id][pdStatTrak][i];
        
kill[i][id]         = userSTATTRAK[id][pdStatTrakKills][i];
    }

I store data like this:
1. level, xp, money, cases and keys.
2. skins that player owns.
3. stattrak skins that player owns + kills of that stattrak.
4. skins that player have in use.


I have changed all my declarations to be var[id][i] and I have checked every line of code and everything looks fine, data is saving for all players. The problem is because I guess beeing a ton of data saved, when there are more than 10 players for example on server and change map, the data is missing for some players, not for all, maybe data is exceeded or idk...
Anyway, I will try to save with SQL, maybe you can give me an example or I will find some tut regarding this kind of save.

Last edited by aEEk; 05-29-2020 at 16:22.
aEEk is offline
Send a message via Yahoo to aEEk Send a message via Skype™ to aEEk
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-29-2020 , 18:09   Re: [INC] nVault Array
Reply With Quote #12

Are you seeing this error in your logs?
Code:
Array size too large, you must increase NVAULT_ARRAY_MAXARRAYSIZE in nvault_array.inc
I would creare an enum like this for your data
PHP Code:
enum PlayerData
{
    
SteamID34],
    
Level,
    
XP,
    
Money
    Cases
,
    
Keys,
    
SkinsMAX_SKINS_PER_PLAYER ],
    
StratakSkinsMAX_SKINS_PER_PLAYER ][ ], //0 = SkinID, 1 = Kills for that skin
    
SkinsInUseMAX_SKINS_PER_PLAYER ]

__________________
Bugsy is offline
aEEk
Member
Join Date: May 2012
Location: Romania
Old 05-29-2020 , 19:06   Re: [INC] nVault Array
Reply With Quote #13

Quote:
Originally Posted by Bugsy View Post
Are you seeing this error in your logs?
Code:
Array size too large, you must increase NVAULT_ARRAY_MAXARRAYSIZE in nvault_array.inc
No, no errors like that in console. Anyway, what is the maxim value possible for const _NVAULT_ARRAY_MAXARRAYSIZE = 500, and what 500 stand for?
aEEk is offline
Send a message via Yahoo to aEEk Send a message via Skype™ to aEEk
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-29-2020 , 19:19   Re: [INC] nVault Array
Reply With Quote #14

nVault Array is really just a hacky way of storing 4-byte integers in a string. For every value you save in an nVault array, it consumes 5 characters of string in the vault. So to keep this from consuming a ton of memory, I capped the default max array size at 500 since the array/buffer needed to accommodate this is 500x5 = 2500 x 4 bytes per cell = 10,000 bytes + 1 null-terminating cell = 10,004 bytes. This can be increased.

This allows you to save up to a 500 cell array:
new Test1[ 500 ];
new Test2[ 2 ][ 250 ];
new Test3[ 5 ][ 100 ];

This is why I think you may be exceeding the max allowed storage, since you are saving a ton of data.
__________________

Last edited by Bugsy; 05-30-2020 at 09:36.
Bugsy is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:08.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode