Raised This Month: $51 Target: $400
 12% 

KeyValues Get Key Name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ReFlexPoison
☠☠☠
Join Date: Jul 2011
Location: ☠☠☠
Old 02-14-2014 , 20:12   KeyValues Get Key Name
Reply With Quote #1

Rather than creating separate sections, how would I got about getting the name of a specific key?
PHP Code:
"Custom Votes"
{
    
"Say something funny"
    
{
        
"type"            "list"
        "minimum"        "0"
        "options"
        
{
            
"lol"        "sm_csay lol"
        
}
    }

I haven't been able to figure out how to get "lol" out of these keys unless I convert it to a seperate section...
PHP Code:
"Custom Votes"
{
    
"Say something funny"
    
{
        
"type"            "list"
        "minimum"        "0"
        "options"
        
{
            
"lol"
            
{
                
"..."        "sm_csay lol"
            
}
        }
    }

Would appreciate any advice.

Btw I don't want to use the config parser. I've never messed with it and don't plan on doing so.

Last edited by ReFlexPoison; 02-14-2014 at 20:13.
ReFlexPoison is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-14-2014 , 23:16   Re: KeyValues Get Key Name
Reply With Quote #2

Assuming you've already drilled down to the "options" key:

PHP Code:
if (KvGotoFirstSubKey(kvfalse))
{
    do
    {
        
decl String:keyName[64];
        
decl String:value[64];
        
KvGetSectionName(kvkeyNamesizeof(keyName));
        
KvGetString(kvNULL_STRINGvaluesizeof(value));
    } while (
KvGotoNextKey(kvfalse));

Note that value can also be other types, but NULL_STRING will fetch the current value if you're iterating over values (which you do when passing false as the second arg to KvGotoFirstSubKey and KvGotoNextKey).
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Reply



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 03:44.


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