PHP Code:
#pragma semicolon 1
#include <sourcemod>
#define MAX_ENTRIES 64
new String:g_sMapFile[MAX_ENTRIES][64];
new String:g_sMapName[MAX_ENTRIES][64];
new g_iCount;
public OnPluginStart() {
ReadKV("mapnames.cfg");
}
public ReadKV(const String:sFile[]) {
new String:sPath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sPath, sizeof(sPath), "configs/%s", sFile);
if(!FileExists(sPath)) {
LogMessage("File does not exist");
return;
}
new Handle:hKV = CreateKeyValues("maps");
FileToKeyValues(hKV, sPath);
g_iCount = 0;
if(KvGotoFirstSubKey(hKV, false)) {
do {
new String:sKey[64];
KvGetSectionName(hKV, sKey, sizeof(sKey));
new String:sValue[64];
KvGetString(hKV, NULL_STRING, sValue, sizeof(sValue));
strcopy(g_sMapFile[g_iCount], 64, sKey);
strcopy(g_sMapName[g_iCount], 64, sValue);
LogMessage("%s is %s", g_sMapFile[g_iCount], g_sMapName[g_iCount]);
g_iCount++;
} while (KvGotoNextKey(hKV, false));
} else {
LogMessage("No map names specified");
}
return;
}
-->
Code:
L 11/20/2010 - 20:47:46: [read_kv.smx] cp_dustbowl is Dustbowl
L 11/20/2010 - 20:47:46: [read_kv.smx] cp_gravelpit is Gravel Pit
L 11/20/2010 - 20:47:46: [read_kv.smx] cp_steel is Steel
L 11/20/2010 - 20:47:46: [read_kv.smx] pl_badwater is Badwater Basin
L 11/20/2010 - 20:47:46: [read_kv.smx] pl_goldrush is Gold Rush
L 11/20/2010 - 20:47:46: [read_kv.smx] pl_hoodoo_final is Hoodoo
__________________