Raised This Month: $ Target: $400
 0% 

nVault not save -solved-


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-15-2012 , 04:50   nVault not save -solved-
Reply With Quote #1

So....i'm using nVault, and when the server is restarted, it doesn't keep the data. Anyone know why this is? Or does nVault just not do that....

Because you guys love reading code so much....this is how i initialize it etc etc
Code:
// global new g_vaultHandle // plugin_init if(get_pcvar_num(frags_pcvar) == 1 && get_pcvar_num(toggle_pcvar) == 1)     {         new mapName[32]; get_mapname(mapName, charsmax(mapName) )         g_vaultHandle = nvault_open("brass_frags") //VaultName)         if(g_vaultHandle == -1)         {             log_amx("[BKF] nVault failed to open. Frags will not be persistent. VaultID: %d. Map: %s", g_vaultHandle, mapName)             log_to_file(nVaultLogFile, "[BKF] nVault failed to open. VaultID: %d. Map: %s", g_vaultHandle, mapName)             set_pcvar_num(frags_pcvar, 0)   // turn off frags             set_pcvar_num(sc_pcvar, 0)  // turn off supercharged mode         }         else             log_to_file(nVaultLogFile, "[BKF] nVault Session Opened and active. VaultID: %d. Map: %s", g_vaultHandle, mapName)     } public plugin_end()    // I have similar code in client_disconnect(id) ->only difference is the for-loop {     if(get_pcvar_num(toggle_pcvar) == 0 || get_pcvar_num(frags_pcvar) == 0)         return         // do a clean up and save of all clients     new players[32], num     new sz_key[34], sz_data[16], name[32]     get_players(players, num, "ch")     for(new i=0, id; i<num; i++)     {         id = players[i]         if(g_idPending[id]) // no point in doing anything if the client isn't authorized             continue                     get_user_authid(id, sz_key, charsmax(sz_key) )         formatex(sz_data, charsmax(sz_data), "%d", gi_playerFrags[id])         get_user_name(id, name, charsmax(name) )                 nvault_set(g_vaultHandle, sz_key, sz_data)         log_to_file(nVaultLogFile, "[BKF] User %s (%s) has been saved to the vault with %s frags.", name, sz_key, sz_data)     }     nvault_close(g_vaultHandle) } // loading data.... new name[32], sz_vaultKey[34], data[5], timestamp     static flag, frags         get_user_name(id, name, charsmax(name) )        // Used to show who we're talking about in logFile         if( !g_playerAuth[id] )     {         g_idPending[id] = true         client_print(id, print_console, "[BKF] %L", id, "AUTH_FAIL_MSG")         gi_playerFrags[id] = 0         log_to_file(nVaultLogFile, "[BKF] User %s has not been authorized. No vault data created.", name)         return -1     }         get_user_authid(id, sz_vaultKey, charsmax(sz_vaultKey))  // we are usest the steamID as vault key     flag = nvault_lookup(g_vaultHandle, sz_vaultKey, data, charsmax(data), timestamp)         if(!flag)     {         frags = 0         nvault_set(g_vaultHandle, sz_vaultKey, "0")         log_to_file(nVaultLogFile, "[BKF] User %s (%s) is a new client and has been added to the vault.", name, sz_vaultKey)     }     else         frags = nvault_get(g_vaultHandle, sz_vaultKey)             gi_playerFrags[id] = frags     g_idPending[id] = false     log_to_file(nVaultLogFile, "[BKF] User %s (%s) has been authorized and loaded with %d frags.", name, sz_vaultKey, frags)     client_print_color(id, DontChange, "[BKF] %L", id, "WELCOME_MSG", frags) public client_disconnect(id) {     g_playerAuth[id] = false    // Clean up the authorization array; no residuals     new name[32]; get_user_name(id, name, charsmax(name) )     if(g_idPending[id])     {         if(get_pcvar_num(log_pcvar) == 1)             log_to_file(nVaultLogFile, "[BKF] User %s has disconnected, but was never authorized. Their frags were never saved.", name)         return     }         new sz_vaultKey[32], data[10]     get_user_authid(id, sz_vaultKey, charsmax(sz_vaultKey) )     formatex(data, charsmax(data), "%d", gi_playerFrags[id])         nvault_set(g_vaultHandle, sz_vaultKey, data)     if(get_pcvar_num(log_pcvar) == 1)         log_to_file(nVaultLogFile, "[BKF] User %s (%s) has been saved to the vault with %s frags.", name, sz_vaultKey, data) }

Those log messages you see are shown as such:
Quote:
L 06/14/2012 - 2114: [BKF] nVault Session Opened and active. VaultID: 0. Map: de_dust
They save between maps and when users disconnect and connect again. But not after restart. Why?
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 06-19-2012 at 14:10. Reason: added client_disconnect code
Liverwiz is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-15-2012 , 08:28   Re: nVault not save
Reply With Quote #2

You haven't shown us how your saving or loading your data?

Also nVault should be closed on plugin_end()
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 06-15-2012 at 08:28.
hornet is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-15-2012 , 12:15   Re: nVault not save
Reply With Quote #3

Quote:
Originally Posted by hornet View Post
You haven't shown us how your saving or loading your data?

Also nVault should be closed on plugin_end()
I didn't think you'd need it because it works between maps and connects. But i updated the above code.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 06-15-2012 at 12:18.
Liverwiz is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-16-2012 , 07:10   Re: nVault not save
Reply With Quote #4

Sorry I didn't see you say that. When you say restart, I'll assume you mean restart from server control panel - Doing so will not tell your plugin to close, its the same as a crash. You need to save your data earlier.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-16-2012 , 11:28   Re: nVault not save
Reply With Quote #5

Quote:
Originally Posted by hornet View Post
Sorry I didn't see you say that. When you say restart, I'll assume you mean restart from server control panel - Doing so will not tell your plugin to close, its the same as a crash. You need to save your data earlier.
Wouldn't that mean that i just loose the data from the last session? Not all of the data in the vault?
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-16-2012 , 19:50   Re: nVault not save
Reply With Quote #6

No, it shouldn't lose the data. Save your player's data individually on client_disconnect() and that should solve your problem.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 06-16-2012 at 22:05.
hornet is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-17-2012 , 23:06   Re: nVault not save
Reply With Quote #7

Quote:
Originally Posted by Liverwiz View Post
Code:
public plugin_end()    // I have similar code in client_disconnect(id) ->only difference is the for-loop
Quote:
Originally Posted by hornet View Post
No, it shouldn't lose the data. Save your player's data individually on client_disconnect() and that should solve your problem.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-18-2012 , 00:26   Re: nVault not save
Reply With Quote #8

I tested your exact code after removing the cvar checks and saved data on disconnect and had no issues with it.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-18-2012 , 00:37   Re: nVault not save
Reply With Quote #9

It looses data after restart. THAT is my problem. Between maps and connections isn't an issue.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-18-2012 , 20:45   Re: nVault not save
Reply With Quote #10

Actually, come to think of it, it makes sense with the way nVault uses it's journal file. You'll just have to not restart your server during play. The alternative is to make a command to close your nVault before you restart your server. You could also close and re-open your nVault each time you save, however I'm not sure how efficient that'd be.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet 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 06:09.


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