This should help you:
Code:
#include <amxmodx>
#include <nvault>
#define VAULTNAME "MyVault" // The name of your vault file
new g_VaultHandle;
public plugin_init()
{
// ...
}
public savexp( id )
{
g_VaultHandle = nvault_open(VAULTNAME);
// Check if the vault opens properly?
if( g_VaultHandle == INVALID_HANDLE )
{
log_amx("Error opening nVault file: %s", VAULTNAME);
}
// Create some vars and get the player's auth id
new szAuthID[33], szXP[21], TimeStamp;
get_user_authid(id, szAuthID, 32);
// Get their XP
nvault_lookup(g_VaultHandle, szAuthID, szXP, 20, TimeStamp)
// Add XP
new iXPamt, iXPcurrent;
iXPamt = str_to_num(szXP); // Their current amount of stored XP
iXPamt += iXPcurrent // Add 2 totals together, iXPcurrent being their current XP amount
// Now we need to convert iXPamt to a string
new szXPamt[21];
num_to_str(iXPamt, szXPamt, 20);
// Save the XP to vault
nvault_set(g_VaultHandle, szAuthID, szXPamt);
}
NOTE: nvault_close is still broken so all of the data will be reset if the server crashes or restarts!
__________________