I'm trying to write all the weapon names onto a keyvalues file. I just can't seem to figure how can I bring the tree position back one level within a loop.
Here is the code.
PHP Code:
char sWeaponAssault[5][32] =
{
"rifle",
"rifle_desert",
"rifle_ak47",
"rifle_sg552",
"rifle_m60",
};
WeaponNamesToFile()
{
// Build file path.
BuildPath(Path_SM, kv_Path, sizeof(kv_Path), "../../cfg/sourcemod/weapon_prefs.txt");
KeyValues kv = new KeyValues("Weapon Prefs");
if(kv.JumpToKey("Assault", true))
{
for(int i; i < sizeof(sWeaponAssault); i++)
{
PrintToServer("Weapon Name %s", sWeaponAssault[i]);
kv.JumpToKey(sWeaponAssault[i], true);
kv.GoBack();
}
}
kv.ExportToFile(kv_Path);
}
This gives me back just the second last array value.
PHP Code:
"rifle_sg552"
{
}
I know, I need to close the handle, but this need to be fixed before hand. Who can help me?
__________________