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)
}
They save between maps and when users disconnect and connect again. But not after restart. Why?