Heya,
I've been having difficulties with keyvalues ( still trying to learn how to use them in SourceMod ). What I'm trying to do is write each new player that joins the game during a map to a file, so I have a list of players and the needed relevant info for those players in a keyvalue file. The problem I'm experiencing is this:
1). It's not writing into a subgroup. Instead it's just writing to the root.
This is what I want it to do
Code:
"roundPlayers"
{
"apocalyptica:24"
{
"IsInfected" "0"
}
"apocalyptica:25"
{
"IsInfected" "0"
}
"apocalyptica:26"
{
"IsInfected" "0"
}
}
and this is what it's doing
Code:
"apocalyptica:26"
{
"IsInfected" "0"
}
2). It's overwriting each previous player with the new player. Example, there's 5 players that joined and the keyvalues file is saying the following.
Code:
"apocalyptica:26"
{
"IsInfected" "0"
}
This is my code. I just have it hooking player_activate right now.
Code:
public Action:HookPlayerActivate(Handle:event, const String:name[], bool:dontBroadcast)
{
new userID = GetEventInt(event,"userid");
decl String:userString[64];
Format(userString,sizeof(userString),"apocalyptica:%i",userID);
new Handle:roundPlayersConfig = CreateKeyValues("roundPlayers");
decl String:path[PLATFORM_MAX_PATH];
BuildPath(Path_SM,path,PLATFORM_MAX_PATH,"configs/km/es_round_players.txt");
FileToKeyValues(roundPlayersConfig,path);
KvGotoNextKey(roundPlayersConfig);
if(KvJumpToKey(roundPlayersConfig,userString,false))
return;
KvJumpToKey(roundPlayersConfig,userString,true);
KvSetNum(roundPlayersConfig,"IsInfected",0);
KeyValuesToFile(roundPlayersConfig,path);
CloseHandle(roundPlayersConfig);
}
Anywho I was hoping someone could please tell me what I'm doing wrong.
Thanks for your time.