
public vault_save(id)
{
	new vault,vkey[128],vdata[1024],authid[33];
	
	vault = nvault_open(PLUGIN_VAULT);
	
	if(vault == INVALID_HANDLE) 
	{
		server_print("nVault returned invalid handle.");
		return PLUGIN_CONTINUE;
	}
	
	get_user_authid(id,authid,32); 
	
	format(vdata,1023,
	"%d %d %d %d %d %f %f %d %d %d %d %d %d %d",
	g_player_experience[id],
	g_player_level[id],
	g_player_attributepoints[id],
	g_player_skillpoints[id],
	g_player_spirit[id],
	g_player_athletic[id],
	g_player_acrobatic[id],
	g_player_endurance[id],
	g_skill[id][P_SKILL_1],
	g_skill[id][P_SKILL_2],
	g_skill[id][P_SKILL_3],
	g_skill[id][P_SKILL_4],
	g_skill[id][P_SKILL_5],
	g_skill[id][P_SKILL_6]);
	
	format(vkey,127,"%s-%s",authid,g_player_class[id]);
	
	nvault_set(vault,vkey,vdata);
	nvault_close(vault);
	
	return PLUGIN_CONTINUE;
}

public vault_load(id)
{
	new vault,vkey[128],vdata[1024],authid[33],vault_check;
	
	vault = nvault_open(PLUGIN_VAULT);
	
	if(vault == INVALID_HANDLE)
	{
		server_print("nVault returned invalid handle.");
		return PLUGIN_CONTINUE;
	}
	
	get_user_authid(id,authid,32);
	
	format(vkey,127,"%s-%s",authid,g_player_class[id]);
	vault_check=nvault_get(vault,vkey,vdata,1023);
	nvault_close(vault);
	
	if(vault_check)
	{
		static data_xp[8],
		data_lvl[8],
		data_ap[8],
		data_sp[8],
		data_spirit[8],
		data_athletic[8],
		data_acrobatic[8],
		data_endurance[8],
		data_skill_1[8],
		data_skill_2[8],
		data_skill_3[8],
		data_skill_4[8],
		data_skill_5[8],
		data_skill_6[8];
		
		parse(vdata,
		data_xp,7,
		data_lvl,7,
		data_ap,7,
		data_sp,7,
		data_spirit,7,
		data_athletic,7,
		data_acrobatic,7,
		data_endurance,7,
		data_skill_1,7,
		data_skill_2,7,
		data_skill_3,7,
		data_skill_4,7,
		data_skill_5,7,
		data_skill_6,7);
		
		g_player_experience[id]=str_to_num(data_xp);
		g_player_level[id]=str_to_num(data_lvl);
		g_player_attributepoints[id]=str_to_num(data_ap);
		g_player_skillpoints[id]=str_to_num(data_sp);
		g_player_spirit[id]=str_to_num(data_spirit);
		
		g_player_athletic[id]=str_to_float(data_athletic);
		g_player_acrobatic[id]=str_to_float(data_acrobatic);
		g_player_endurance[id]=str_to_num(data_endurance);
		
		g_skill[id][P_SKILL_1]=str_to_num(data_skill_1);
		g_skill[id][P_SKILL_2]=str_to_num(data_skill_2);
		g_skill[id][P_SKILL_3]=str_to_num(data_skill_3);
		g_skill[id][P_SKILL_4]=str_to_num(data_skill_4);
		g_skill[id][P_SKILL_5]=str_to_num(data_skill_5);
		g_skill[id][P_SKILL_6]=str_to_num(data_skill_6);
	}
	else
	{
		reset_player(id);
		reset_player_attributes(id);
		reset_player_skills(id);
		restore_cooldowns(id);
		restore_player(id);
	}
	
	return PLUGIN_CONTINUE;
}
