I'm indexing coordinates around the map for a teleport plugin and i'm having trouble setting up the keyvalues retrieval. I wrote a simple test plugin to try and read the value at
locations > clocktower > emp > x
but i get this error:
KeyValues Error: RecursiveLoadFromBuffer: got EOF instead of keyname in file addons/sourcemod/teleportlocations.txt
locations, (*clocktower*), (*prime*),
PHP Code:
"locations"
{
"clocktower"
{
"ct"
{
"x" "-129"
"y" "5127"
"z" "-1390"
}
"emp"
{
"x" "-3805"
"y" "-5324"
"z" "-1370"
}
"prime"
{
"x" "-1125"
"y" "-45"
"z" "-1340"
}
}
}
PHP Code:
public Action:CMD_TEST(client, args) {
new value = GetCoord("emp", "x");
PrintToChat(client, "%d", value);
}
GetCoord(const String:Location[], const String:Coord[]) {
new value
decl String:MapName[64];
GetCurrentMap(MapName, sizeof(MapName));
new Handle:kv = CreateKeyValues("locations");
FileToKeyValues(kv, "addons/sourcemod/teleportlocations.txt");
KvJumpToKey(kv, MapName, false);
KvJumpToKey(kv, Location, false);
value = KvGetNum(Handle:kv, Coord);
CloseHandle(kv);
return value;
}