Raised This Month: $32 Target: $400
 8% 

How parse keyvalues??


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 06-25-2016 , 15:09   How parse keyvalues??
Reply With Quote #1

Solved:

PHP Code:
                decl String:szSection[64], String:szValue[64];
                
KvGotoFirstSubKey(hKvFilefalse);
                do
                {
                    
KvGetSectionName(hKvFileszSectionsizeof(szSection));
                    
LogMessage(szSection);

                    if (
KvGetDataType(hKvFileNULL_STRING) != KvData_None)
                    {
                        
KvGetString(hKvFileNULL_STRINGszValuesizeof(szValue));
                        
LogMessage(szValue);
                    }
                    else
                    {
                        new 
iDefIndex KvGetNum(hKvFile"index", -1);
                        if (
iDefIndex != -1)
                        {
                            
LogMessage("success %i"iDefIndex);
                        }
                    } 
Thanks to benoist and his voice changer plugin:
https://forums.alliedmods.net/showthread.php?p=2407890



So I have a keyvalue.cfg like so:

Spoiler


And some code to traverse it that doesn't really work properly.

Spoiler


The output looks like this:

Spoiler


Notice that it stops at "set nade detonate timer".

This is the first area in the config where multiple sub-sections in a row appear.

Also, if the first "keyvalue" isn't a sub-section, but is instead just a normal key value pair, it just doesn't read anything at all.

For example, if I put "test" "123" above "cloak is phase shift", LogMessage never fires. We just get this:

Spoiler


How can I make this work?

I'm about ready to just use .json and require the smjannsen extension instead, but it'd be nice if that could be avoided.
__________________

Last edited by Chdata; 06-25-2016 at 15:40.
Chdata is offline
Reply


Thread Tools
Display Modes

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 06:49.


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