well my plugin uses SQL methodology that I stole from War3FT so if you want SQL look there. For Vault saving I am using nVault, but it is my first time, so I am not sure if I got the syntax right...
Code:
public vSaveXP(id) {
#if defined DEBUG
debug_log("Begining: vSaveXP(id), id=%i", id);
#endif
if(pdata[id][PCLASS] == CLASS_NOTHING || is_user_bot(id)
|| !get_pcvar_num(pcvar[SAVEXP]) || pdata[id][PXP] == 0)
return PLUGIN_CONTINUE;
//make sure player has steam ID
new playerID[32];
get_user_authid(id, playerID, 31);
if(get_pcvar_num(pcvar[SAVEBY]) == SAVEBY_STEAMID
&& equal(playerID, "STEAM_ID_PENDING"))
return PLUGIN_CONTINUE;
new playerIP[20], name[33];
get_user_name(id, name, 32);
get_user_ip(id, playerIP, 19);
new szKey[128], szData[512];
//actual data to be saved.
format(szData, 511, "%d %d %d %d %s", classxp[id][CLASS_PREDATOR], classxp[id][CLASS_ALIEN], classxp[id][CLASS_MARINE], get_systime(), name);
//the key to the vault data.
if(get_pcvar_num(pcvar[SAVEBY]) == SAVEBY_STEAMID)
format(szKey, 127, "%s", playerID);
else if(get_pcvar_num(pcvar[SAVEBY]) == SAVEBY_IP)
format(szKey, 127, "%s", playerIP);
else
format(szKey, 127, "%s", name);
new vault = nvault_open(PLUGIN_VAULT);
if(vault == INVALID_HANDLE) {
avp_log("ERROR: Unable to open vault file %s", PLUGIN_VAULT);
return PLUGIN_CONTINUED;
}
//saves
nvault_set(vault, szKey, szData);
nvault_close(vault);
vSaveSkill(id);
return PLUGIN_CONTINUE;
}
public vLoadXP(id) {
#if defined DEBUG
debug_log("Begining: vLoadXP(id), id=%i", id);
#endif
if(!get_pcvar_num(pcvar[SAVEXP]) || !id)
return PLUGIN_CONTINUE;
//check SteamID
new playerID[32], name[33];
get_user_authid(id, playerID, 31);
get_user_name(id, name, 32);
if(get_pcvar_num(pcvar[SAVEBY]) == SAVEBY_STEAMID && equal(playerID, "STEAM_ID_PENDING")) {
client_print(id, print_chat, "%L", LANG_PLAYER, "STEAM_ID_PENDING_LOADING_ERROR", MOD);
avp_log("ERROR: player's(%i) exp could not be loaded. SteamID was: %s", id, playerID);
return PLUGIN_CONTINUE;
}
new playerIP[20];
get_user_ip(id, playerIP, 19);
new szKey[128], szData[256], data;
//vault key, must unlock it :)
if(get_pcvar_num(pcvar[SAVEBY]) == SAVEBY_STEAMID)
format(szKey, 127, "%s", playerID);
else if(get_pcvar_num(pcvar[SAVEBY]) == SAVEBY_IP)
format(szKey, 127, "%s", playerIP);
else
format(szKey, 127, "%s", name);
new vault = nvault_open(PLUGIN_VAULT);
if(vault == INVALID_HANDLE) {
avp_log("ERROR: Unable to open vault file %s", PLUGIN_VAULT);
return PLUGIN_CONTINUED;
}
data = nvault_get(vault, szKey, szData, 255);
nvault_close(vault);
//ok there is something in vault lets check it out.
if(data) {
new datPredXP[8], datAlienXP[8], datMarinXP[8];
//break it up baby, break it up!!
parse(szData, datPredXP, 7, datAlienXP, 7, datMarinXP, 7);
//now I guess I can take this stored data from vault,
//store it in the a temporary storage bin, then store the
//data in that temporary storage bin into another storage bin
//that is a global storage bin and the stored data has been
//stored now in the bigger storage bin and everything is STORED!!
classxp[id][CLASS_PREDATOR] = str_to_num(datPredXP);
classxp[id][CLASS_ALIEN] = str_to_num(datAlienXP);
classxp[id][CLASS_MARINE] = str_to_num(datMarinXP);
} else { //nothing there, so just restart them.
classxp[id][CLASS_PREDATOR] = (get_pcvar_num(pcvar[STRTLVL]) == 0) ? 0 : LEVELS[get_pcvar_num(pcvar[STRTLVL])-1];
classxp[id][CLASS_ALIEN] = (get_pcvar_num(pcvar[STRTLVL]) == 0) ? 0 : LEVELS[get_pcvar_num(pcvar[STRTLVL])-1];
classxp[id][CLASS_MARINE] = (get_pcvar_num(pcvar[STRTLVL]) == 0) ? 0 : LEVELS[get_pcvar_num(pcvar[STRTLVL])-1];
}
ShowHUD(id);
pdata[id][PXP] = (pdata[id][PCLASS] == CLASS_NOTHING) ? 0 : classxp[id][pdata[id][PCLASS]];
pdata[id][PLEVEL] = Calc_Player_Level(id);
return PLUGIN_CONTINUE;
}