Raised This Month: $404 Target: $400
 101% 

nVault Tutorial


Post New Thread Reply   
 
Thread Tools Display Modes
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 05-02-2009 , 15:36   Re: nVault
Reply With Quote #11

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 #12

Thanks Exolent for catching the typo. +k
__________________
Bugsy 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 #13

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 #14

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 #15

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 #16

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
tm.
Member
Join Date: Apr 2010
Old 04-22-2010 , 02:26   Re: nVault
Reply With Quote #17

Thanks for the tutorial, it has been useful for me.
Quote:
Originally Posted by fysiks View Post
Would there be file access issues if you tried to access a single nVault from two plugins? Just curious really.
Same question.
And how many entries is to much for nvault?
tm. is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Brazil
Old 04-22-2010 , 16:08   Re: nVault
Reply With Quote #18

Quote:
Originally Posted by fysiks View Post
Would there be file access issues if you tried to access a single nVault from two plugins?
File access protection is based on the process, and there's only one process accessing all the vaults: hl.exe, so no problems.

Of course there's the problem two or more threads can't write to one file at the same time, but this isn't an issue, since AMXx runs on a single thread.
Seta00 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-22-2010 , 16:35   Re: nVault
Reply With Quote #19

Yeah, I figured that was the case.
__________________
fysiks is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 08-18-2010 , 13:32   Re: nVault
Reply With Quote #20

Can anyone help me with storing multiple data.
Code:
#include < amxmodx >
#include < nvault >

new g_iVaultID
new g_szSteamID[ 33 ][ 34 ]
new g_iData[ 33 ] 
new g_iData2[ 33 ] 
new g_iData3[ 33 ] 
new g_iData4[ 33 ] 
new g_iData5[ 33 ] 
new g_iData6[ 33 ] 

public plugin_init( )
{
    register_plugin( "Shit", "Crap", "Lol" )
    
    register_clcmd( "say /show", "fn_Show" )
    register_clcmd( "say /save", "fn_Save" )
}

public plugin_end( )
{
    nvault_close( g_iVaultID )
}

public plugin_cfg( )
{
    g_iVaultID = nvault_open( "test_vault" )
    
    if( g_iVaultID == INVALID_HANDLE )
    {
        set_fail_state( "Error opening Test Nvault" )
    }
}

public client_putinserver( Player )
{
    get_user_authid( Player, g_szSteamID[ Player ], charsmax( g_szSteamID[ ] ) )
    
    Load_Stuff( Player )
}

public fn_Show( Player )
{
    client_print( Player, print_chat, "Data1: %d; Data2: %d; Data3: %d; Data4: %d; Data5:%d; Data6: %d", g_iData[ Player ], g_iData2[ Player ], g_iData3[ Player ], g_iData4[ Player ], g_iData5[ Player ], g_iData6[ Player ] )
}

public fn_Save( Player )
{
    new szSteamID[ 34 ]
    formatex( szSteamID, charsmax( szSteamID ), "%sTEST", g_szSteamID[ Player ] )
    
    g_iData[ Player ] = random_num( 0, 200 )
    g_iData2[ Player ] = random_num( 201, 400 )
    g_iData3[ Player ] = random_num( 401, 600 )
    g_iData4[ Player ] = random_num( 601, 800 )
    g_iData5[ Player ] = random_num( 801, 999 )
    g_iData6[ Player ] = random_num( 1000, 1099 )
    
    new szData[ 50 ]
    formatex( szData, charsmax( szData ), "%d %d %d %d %d %d", g_iData[ Player ], g_iData2[ Player ], g_iData3[ Player ], g_iData4[ Player ], g_iData5[ Player ], g_iData6[ Player ] )
    
    nvault_set( g_iVaultID, szSteamID, szData )
    
    client_print( Player, print_chat, "Data1: %d; Data2: %d; Data3: %d; Data4: %d; Data5:%d; Data6: %d", g_iData[ Player ], g_iData2[ Player ], g_iData3[ Player ], g_iData4[ Player ], g_iData5[ Player ], g_iData6[ Player ]  )
}

Load_Stuff( Player )
{
    new szData[ 50 ], szSteamID[ 34 ]
    formatex( szSteamID, charsmax( szSteamID ), "%sTEST", g_szSteamID[ Player ] )
    
    if( nvault_get( g_iVaultID, szSteamID, szData, 49 ) )
    {
        new iSpacePos = contain( szData, " " )
        
        if( iSpacePos > -1 )
        {
            new szData1[ 4 ], szData2[ 4 ], szData3[ 4 ], szData4[ 4 ], szData5[ 4 ], szData6[ 5 ]
            formatex( szData1, iSpacePos, "%s", szData )
            formatex( szData2, 3, "%s", szData[ iSpacePos + 1 ] )
            formatex( szData3, 3, "%s", szData2[ iSpacePos + 1 ] )
            formatex( szData4, 3, "%s", szData3[ iSpacePos + 1 ] )
            formatex( szData5, 3, "%s", szData4[ iSpacePos + 1 ] )
            formatex( szData6, 4, "%s", szData5[ iSpacePos + 1 ] )
            
            
            g_iData[ Player ] = str_to_num( szData1 )
            g_iData2[ Player ] = str_to_num( szData2 )
            g_iData3[ Player ] = str_to_num( szData3 )
            g_iData4[ Player ] = str_to_num( szData4 )
            g_iData5[ Player ] = str_to_num( szData5 )
            g_iData6[ Player ] = str_to_num( szData6 )
        }
    }
}
I dont why, but g_iData[ ] values all the time are 0.
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Old 08-18-2010, 18:28
Bugsy
This message has been deleted by Bugsy.
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 07:28.


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