Raised This Month: $ Target: $400
 0% 

Solved nvault_set_array integer key


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-30-2018 , 09:09   nvault_set_array integer key
Reply With Quote #1

What can I do if I want to use an integer as a key when using nvault_set_array? It only supports string which isn't useful for me. I'm unable to use player name/steamid as the key because there will be multiple entries from the same person. So that's why an integer would be the ideal thing.
__________________

Last edited by edon1337; 07-31-2018 at 08:03.
edon1337 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-30-2018 , 09:16   Re: nvault_set_array integer key
Reply With Quote #2

There should be no reason for multiple rows, why not pack all data into 1 array?
__________________
Bugsy is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-30-2018 , 09:18   Re: nvault_set_array integer key
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
There should be no reason for multiple rows, why not pack all data into 1 array?
I already packed the data into a single array?
PHP Code:
@MessageStartid )
{
    new 
szArgs128 ], szName32 ], szMessageCount];
    
read_argsszArgscharsmaxszArgs ) );
    
    
remove_quotesszArgs );
    
    
g_iMessageCount++;
    
num_to_strg_iMessageCountszMessageCountcharsmaxszMessageCount );
    
    
get_user_nameidszNamecharsmaxszName ) );
    
    new 
eDataMessageStruct ];
    
    
eDataMessage_Text ] = szArgs;
    
eDataMessage_Sender ] = szName;
    
    
nvault_set_arrayg_iVaultHandleg_iMessageCounteDatasizeofeData[ ] ) ); 
EDIT: Oh I get what you meant, I can't pack all data in one array because each entry should be on their own.
__________________

Last edited by edon1337; 07-30-2018 at 09:20.
edon1337 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-30-2018 , 09:21   Re: nvault_set_array integer key
Reply With Quote #4

Lets start with explaining what you are trying to accomplish.
__________________
Bugsy is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-30-2018 , 09:23   Re: nvault_set_array integer key
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
Lets start with explaining what you are trying to accomplish.
We could simplify everything by saying that I can't pack all data from a user in one array.

I'm doing a menu that lets players create messages that get stored in nVault, and then people with specified access can see every stored message.
__________________
edon1337 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-30-2018 , 09:27   Re: nvault_set_array integer key
Reply With Quote #6

That was based on what you stated in your first post. What do you plan to use as an integer key that will be unique to the player? Numbers from the steamid?
__________________
Bugsy is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-30-2018 , 09:30   Re: nvault_set_array integer key
Reply With Quote #7

Quote:
Originally Posted by Bugsy View Post
That was based on what you stated in your first post. What do you plan to use as an integer key that will be unique to the player? Numbers from the steamid?
It doesn't have to do anything with the player, as they aren't affected, I've created a global variable that gets increased by 1 every time a new message is created, that's what I'm planning to use as the id key.
__________________
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-30-2018 , 10:21   Re: nvault_set_array integer key
Reply With Quote #8

I'm not really going to bother figuring out a proper saving system, maybe bugsy will.
If you want to use integer as key then use num_to_str.
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-30-2018 , 10:27   Re: nvault_set_array integer key
Reply With Quote #9

Quote:
Originally Posted by HamletEagle View Post
I'm not really going to bother figuring out a proper saving system, maybe bugsy will.
This is already the proper way, just that it doesn't support int as a key.

Quote:
Originally Posted by HamletEagle View Post
If you want to use integer as key then use num_to_str.
Guess that's the only solution
__________________

Last edited by edon1337; 07-30-2018 at 10:27.
edon1337 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-30-2018 , 10:35   Re: nvault_set_array integer key
Reply With Quote #10

Its not something worthwhile to implement in nvault array since ultimately nvault array will need to convert the number back to a string to use it as the key. This limitation is at the nvault module level, not nvault array.
__________________
Bugsy is offline
Reply



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 12:15.


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