So Im trying to create a KeyValue file that contains some info I need to save each map change.
Below is the code I use to create the KeyValue file.
g_szModConfigFilePath = cfg/votemod/nextmod.txt
PHP Code:
stock CreateModFile(iNextMod)
{
new Handle:hDataPack = GetArrayCell(g_hModArray, iNextMod);
decl String:szModName[32], String:szModDir[PLATFORM_MAX_PATH], String:szModCfg[32], String:szModMap[32], String:szModPlugin[32];
/* Read the Mod Info from the data pack */
ReadPackString(hDataPack, szModName, sizeof(szModName));
ReadPackString(hDataPack, szModDir, sizeof(szModDir));
ReadPackString(hDataPack, szModCfg, sizeof(szModCfg));
ReadPackString(hDataPack, szModMap, sizeof(szModMap));
ReadPackString(hDataPack, szModPlugin, sizeof(szModPlugin));
CloseHandle(hDataPack);
/* Create the KeyValue File */
new Handle:hKeyValue = CreateKeyValues("NextMod");
KvJumpToKey(hKeyValue, szModName, true);
KvSetString(hKeyValue, "dir", szModDir);
KvSetString(hKeyValue, "cfg", szModCfg);
KvSetString(hKeyValue, "map", szModMap);
KvSetString(hKeyValue, "plugin", szModPlugin);
KeyValuesToFile(hKeyValue, g_szModConfigFilePath);
CloseHandle(hKeyValue);
/* Show Next Mod to Players */
PrintToChatAll("[%s] The next mod will be: %s", szModName);
PrintToServer("[%s] The next mod will be: %s", szModName);
}
And this is the output file. Its not creating the root of the KV but the section its creating has the correct info.
Code:
"Outlaws" //Menu Item
{
"dir" "outlaws"
"cfg" "outlaws-config.cfg"
"map" "outlaws-maps.txt"
"plugin" "outlaws-plugins.ini"
}