Raised This Month: $ Target: $400
 0% 

Saving ip's into nvault


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 07-06-2012 , 19:59   Re: Saving ip's into nvault
Reply With Quote #2

You need to initialize a person into the vault before you can save, or get their data. Check out my code from a plugin i use nvault for.

PHP Code:
retrieveFrags(id)    // gets the frags for the given clientID from vualt  @RETURNS player's frags or -1 if not authorized
{
    if(
get_pcvar_num(frags_pcvar) == || get_pcvar_num(toggle_pcvar) == 0)
    {
        
client_print(idprint_console"[AMX] %L"id"DISABLED")
        return 
PLUGIN_HANDLED
    
}
    if(!
is_user_connected(id) || is_user_bot(id))
        return -
1
    
    
new name[32], sz_vaultKey[34], data[5], timestamp
    
static frags
    
    get_user_name
(idnamecharsmax(name) )        // Used to show who we're talking about in logFile
        // This makes sure the user has a valid AuthID
    
if( !g_playerAuth[id] )
    {
        
g_idPending[id] = true
        client_print
(idprint_console"[BKF] %L"id"AUTH_FAIL_MSG")
        
gi_playerFrags[id] = 0
        
if(get_pcvar_num(log_pcvar) == 1)
            
log_to_file(nVaultLogFile"[BKF] User %s has not been authorized. No vault data created."name)
        return -
1
    
}
    
    
get_user_authid(idsz_vaultKeycharsmax(sz_vaultKey))  // we are usest the steamID as vault key
    
    
if(!nvault_lookup(g_vaultHandlesz_vaultKeydatacharsmax(data), timestamp))
    {
        
frags 0
        nvault_set
(g_vaultHandlesz_vaultKey"0")
        if(
get_pcvar_num(log_pcvar) == 1)
            
log_to_file(nVaultLogFile"[BKF] User %s (%s) is a new client and has been added to the vault."namesz_vaultKey)
    }
    else
        
frags nvault_get(g_vaultHandlesz_vaultKey)
        
    
gi_playerFrags[id] = frags
    g_idPending
[id] = false
    
if(get_pcvar_num(log_pcvar) == 1)
        
log_to_file(nVaultLogFile"[BKF] User %s (%s) has been authorized and loaded with %d frags."namesz_vaultKeyfrags)
    
client_print_color(idDontChange"[BKF] %L"id"WELCOME_MSG"frags)
    
    return 
frags

P.S. Read and understand the code. Don't just copy/paste it.
This code is run at client_putinserver

also....don't use parse and replace all to seperate your data use strtok, it'll save you some native calls.
Code:
strtok(vaultdata, kills, charsmax(kills), deaths, charsmax(deaths), '#', 1)
This will not remove the final #. Take it out. you don't need it, unless you have plans for it later.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
 



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


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