AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved nvault_set_array integer key (https://forums.alliedmods.net/showthread.php?t=309556)

edon1337 07-30-2018 09:09

nvault_set_array integer key
 
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.

Bugsy 07-30-2018 09:16

Re: nvault_set_array integer key
 
There should be no reason for multiple rows, why not pack all data into 1 array?

edon1337 07-30-2018 09:18

Re: nvault_set_array integer key
 
Quote:

Originally Posted by Bugsy (Post 2607044)
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.

Bugsy 07-30-2018 09:21

Re: nvault_set_array integer key
 
Lets start with explaining what you are trying to accomplish.

edon1337 07-30-2018 09:23

Re: nvault_set_array integer key
 
Quote:

Originally Posted by Bugsy (Post 2607047)
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.

Bugsy 07-30-2018 09:27

Re: nvault_set_array integer key
 
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?

edon1337 07-30-2018 09:30

Re: nvault_set_array integer key
 
Quote:

Originally Posted by Bugsy (Post 2607050)
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.

HamletEagle 07-30-2018 10:21

Re: nvault_set_array integer key
 
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.

edon1337 07-30-2018 10:27

Re: nvault_set_array integer key
 
Quote:

Originally Posted by HamletEagle (Post 2607070)
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 (Post 2607070)
If you want to use integer as key then use num_to_str.

Guess that's the only solution

Bugsy 07-30-2018 10:35

Re: nvault_set_array integer key
 
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.


All times are GMT -4. The time now is 12:15.

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