Raised This Month: $ Target: $400
 0% 

[Question] Keyvalues GRRR!


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
SamuraiBarbi
Senior Member
Join Date: Aug 2006
Location: United States
Old 09-13-2007 , 12:25   [Question] Keyvalues GRRR!
Reply With Quote #1

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.

Last edited by SamuraiBarbi; 09-13-2007 at 12:29.
SamuraiBarbi is offline
Send a message via AIM to SamuraiBarbi Send a message via MSN to SamuraiBarbi Send a message via Yahoo to SamuraiBarbi
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:54.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode