Raised This Month: $174 Target: $400
 43% 

[INC] nVault Array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-17-2016 , 13:42   [INC] nVault Array
Reply With Quote #1

nVault Array

This include provides the ability to store arrays in nVault. Out of the box, nVault allows you to only save data as a single string. This is cumbersome when you need to store multiple pieces of data because you first need to convert it to a single sting before saving. On top of that, when retrieving the data you then need to parse each value out of the string and then convert it back to an integer and/or copy it back to a string/float variable. This include file solves this problem by allowing you to save and retrieve data directly to and from an array. Data of various types (int, bool, string, float) can all be stored in a single array by using an enum sized array (see example plugin).

Note: This include file requires that you use a fixed version of the nVault module. During the development of these new functions, a bug was discovered in the nVault module that will result in invalid values and possibly errors. This fixed module is attached below and is also available in AMX-X dev builds >= 4589. Thanks to Arkshine for fixing this so quickly for me.

Functions
  • nvault_set_array() - Save an array to vault.
  • nvault_get_array() - Read an array from vault.
  • nvault_arraysize() - Returns size of array stored.
  • nvault_isarray() - Returns true/false for if data is an array.
Note: This include file uses the nVault handle returned from nvault_open(). It does NOT use the nvault_util_open() file handle used by nVault Utility. This include file has no dependency on nVault Utility. nVault Utility does, however, provide the ability to read all array entries. For nvault_util_read_array()/nvault_util_readall_array(), you would use the nvault_util_open() file handle as with all functions in nVault Utility.

Descriptions
  • nvault_set_array( vault , key , array[] , size )
    This function saves an array to vault. The largest array that can be saved is 500 cells; you can increase this by increasing the constant _NVAULT_ARRAY_MAXARRAYSIZE in the include file. Multidimensional arrays are not directly supported, but if you use an enum to size your array, it can be accomplished. Arrays are stored in a binary format with encoding to prevent null bytes from being included in the output string .. which means you cannot edit/view arrays saved in nVault with an nVault viewer application.
    Code:
    vault - Vault handle.
    key - Key for entry.
    array[] - Array to store in vault.
    size - Size of array.
  • nvault_get_array( vault , key , array[] , size )
    This function reads an array from vault. This will only read arrays that were stored in the vault using nvault_set_array().
    Code:
    vault - Vault handle.
    key - Key for entry.
    array[] - Array to read data in to.
    size - Size of array.
  • nvault_arraysize( vault , key )
    This function returns the size of the array data stored in nvault. It will return 0 if the record does not exist or if the data in the nVault record is not an array. It will otherwise return the size of the array in cells.
    Code:
    vault - Vault handle.
    key - Key for entry.
  • nvault_isarray( vault , key )
    This function determines whether or not the data is an array.
    Code:
    vault - Vault handle.
    key - Key for entry.
nVault Array Example
Spoiler
Attached Files
File Type: zip nvault_amxx_fixed.zip (148.2 KB, 121 views)
File Type: inc nvault_array.inc (7.6 KB, 227 views)
__________________

Last edited by Bugsy; 01-10-2018 at 00:04.
Bugsy is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Europe (ro)
Old 12-18-2016 , 03:48   Re: [INC] nVault Array
Reply With Quote #2

First Comment.

Amazing WORK BUGSYYYYYYYY

Last edited by Craxor; 12-18-2016 at 03:49.
Craxor is offline
Send a message via ICQ to Craxor
EFFx
Veteran Member
Join Date: Feb 2016
Location: SP, Brazil
Old 12-18-2016 , 14:16   Re: [INC] nVault Array
Reply With Quote #3

Quote:
Originally Posted by Craxor View Post
Amazing WORK BUGSYYYYYYYY
Bugsy is the daddy of Arrays
__________________
EFFx is offline
Send a message via Skype™ to EFFx
shehzad1234
Senior Member
Join Date: Jan 2016
Old 12-21-2016 , 10:24   Re: [INC] nVault Array
Reply With Quote #4

Awsome
__________________
Contact : Facebook
All Join -=}BBI{=- Hns Server :- 103.50.161.8:10001
shehzad1234 is offline
ish12321
Veteran Member
Join Date: May 2016
Old 06-17-2018 , 09:29   Re: [INC] nVault Array
Reply With Quote #5

Could you also add nvault_pset_array ?
__________________
['O|s|G'] | Death Wins a.k.a Ish Chhabra was here
ish12321 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-17-2018 , 13:00   Re: [INC] nVault Array
Reply With Quote #6

Quote:
Originally Posted by ish12321 View Post
Could you also add nvault_pset_array ?
Yes, I'll add it when I get a chance. For now, you can see if the below works:
PHP Code:
nvault_touchvault key ); 
__________________

Last edited by Bugsy; 06-17-2018 at 13:01.
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 05:34.


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