This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

nVault Tutorial


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 05-02-2009 , 14:59   Re: nVault
Reply With Quote #1

Quote:
Originally Posted by Bugsy View Post
The overhead for SQL isn't always necessary for basic data storage. nVault also does not require the knowledge of how to write queries. nVault provides a very basic and easy to understand means of saving\retrieving data to an external file.
This is why I said I'm going to stick with SQL, since I know how to query it is not a problem for me . It's definitely a helpful and nice tutorial for everyone else but as long as it is not extremely incomplex, temporary or limited data that has to be stored I will always use SQL.

Question: I have a bad opinion about vaults ever since my old WC3 Server suffered from a huge XP-database and crashed on every mapchange. Is this still possible with nVault?
__________________
In Flames we trust!
Nextra is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-02-2009 , 15:32   Re: nVault
Reply With Quote #2

Quote:
Originally Posted by Nextra View Post
This is why I said I'm going to stick with SQL, since I know how to query it is not a problem for me . It's definitely a helpful and nice tutorial for everyone else but as long as it is not extremely incomplex, temporary or limited data that has to be stored I will always use SQL.

Question: I have a bad opinion about vaults ever since my old WC3 Server suffered from a huge XP-database and crashed on every mapchange. Is this still possible with nVault?
Even if querying isn't a problem for you it could still be overkill depending on what you are storing. If you are only storing a single item and only need to retrieve it based on a single key then it is a waste of CPU to use SQL. Whatever floats your boat though.

I've never had any issues with nVault. I have used it for all of my data saving needs.
__________________
Bugsy is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 05-02-2009 , 15:36   Re: nVault
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
Even if querying isn't a problem for you it could still be overkill depending on what you are storing. If you are only storing a single item and only need to retrieve it based on a single key then it is a waste of CPU to use SQL. Whatever floats your boat though.
Of course. As I said: If it's uncomplex or temporary data I wouldn't bother doing a SQL-implementation.
__________________
In Flames we trust!
Nextra is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-02-2009 , 16:20   Re: nVault
Reply With Quote #4

Thanks Exolent for catching the typo. +k
__________________
Bugsy is offline
ish12321
Veteran Member
Join Date: May 2016
Old 06-17-2018 , 08:31   Re: nVault Tutorial
Reply With Quote #5

Is it possible to have 2 entries with same key ?
__________________
['O|s|G'] | Death Wins a.k.a Ish Chhabra was here
ish12321 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-02-2009 , 13:34   Re: nVault
Reply With Quote #6

Good job! I always wanted to know how to use the prune function.

PHP Code:
public cmdSaveScore(id)
{
    
//Save 2 items into the value of the entry.
    //Example: STEAM_0:0:1234 15 5

    
new szData[8];
    new 
szKey[40];
    
formatexszKey 39 "%sMONEY" g_szAuthID[id] );
    
formatexszData "%d %d" get_user_kills(id) , get_user_deaths(id) );

    
nvault_setg_Vault szKey szData );

    
client_printid print_chat "* Your score was saved to vault." );
}

public 
cmdGetScore(id)
{
    
//Read 2 items that that are saved in the same entry
    //Example: STEAM_0:0:1234 15 5

    
new szData[8];
    new 
szKey[40];
    
formatexszKey 39 "%sMONEY" g_szAuthID[id] );

    if ( 
nvault_getg_Vault szKey szData ) )
    {
        new 
iSpacePos containszData " " );
        new 
szKills[4];
        new 
szDeaths[4];
        
        if ( 
iSpacePos > -)
        {    
            
formatexszKills iSpacePos "%s" szData );
            
formatexszDeaths "%s" szDataiSpacePos ] );

            
set_user_killsid str_to_numszKills );
            
set_user_deathsid str_to_numszDeaths );

            
client_printid print_chat "* Your score was loaded: %s kills, %s deaths" szKills szDeaths );
        }
    }
    else
    {
        
client_printid print_chat "* You have no score entry in vault." );
    }

Don't you mean:
PHP Code:
formatexszKey 39 "%sSCORE" g_szAuthID[id] ); 
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-25-2009 , 11:33   Re: nVault
Reply With Quote #7

Made corrections to example plugin. There were a few minor typo's and added required modules to make it compile via copy and paste.
__________________
Bugsy is offline
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 01-14-2010 , 00:03   Re: nVault
Reply With Quote #8

If you could add a function to return just the timestamp for a vault key that would be great.

Code:
nvault_timestamp(vault, key[]); // Finds when the item was last touched.

Also, it would be awesome it we could write as to the save to the vault in the same data type that it was intended to be in.
__________________

Last edited by Dygear; 01-14-2010 at 00:13.
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-14-2010 , 00:39   Re: nVault
Reply With Quote #9

Code:
stock nvault_timestamp(const vault, const key[]) {     static data[2], timestamp;     return nvault_lookup(vault, key, data, charsmax(data), timestamp) ? timestamp : 0; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
r4ndomz
Senior Member
Join Date: Jul 2009
Location: The Hood
Old 02-21-2010 , 09:56   Re: nVault
Reply With Quote #10

Thanks for the tut!
__________________
HideNSeek bug fixed here:http://forums.alliedmods.net/showpos...&postcount=951

PM me if you want a nice HideNSeek shop
NEED PLUGIN TESTERS PM ME
r4ndomz is offline
Send a message via Skype™ to r4ndomz
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 06:05.


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