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

KeyValues error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Facksy
Senior Member
Join Date: Apr 2017
Location: +2+2
Old 04-22-2018 , 20:05   KeyValues error
Reply With Quote #1

Hey i got problems with keyvalues:
PHP Code:
public Action:Test(clientargs)
{
    
BuildPath(Path_SMKvPathsizeof(KvPath), "configs/admins.cfg");
    new 
Handle:DB CreateKeyValues("ddd");
    
FileToKeyValues(DBKvPath);

It replies me:
Code:
KeyValues Error: LoadFromBuffer: missing { in file addons\sourcemod\configs\admi
ns.cfg
(*Admins*), (*Me*),
KeyValues Error: LoadFromBuffer: missing { in file addons\sourcemod\configs\admi
ns.cfg
(*Admins*), (*Me*),
My admins.cfg is like that:
Code:
Admins
{
    "Me"
    {
		"auth"			"steam"
		"identity"		"STEAM_0:0:75807078"
		"flags"			"z"
    }
}
Can you help me?

Last edited by Facksy; 04-22-2018 at 20:05.
Facksy is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 04-22-2018 , 21:59   Re: KeyValues error
Reply With Quote #2

First of all try using the new Syntax.

PHP Code:
public Action Test(int clientint args)
{
    
BuildPath(Path_SMKvPathsizeof(KvPath), "configs/admins.cfg");
    
KeyValues kv = new KeyValues("ddd");
    
kv.ImportFromFile(KvPath);    

Your admins.cfg file seems a bit off as well. I'm sure someone will correct me, if I'm wrong, but I think this is how it should be.

PHP Code:
"Me"
{
    
"auth"            "steam"
    "identity"        "STEAM_0:0:75807078"
    "flags"            "z"

If you want to use a custom tree then you need "" around admins like this.

PHP Code:
"Admins"
{
    
"Me"
    
{
        
"auth"            "steam"
        "identity"        "STEAM_0:0:75807078"
        "flags"            "z"
    
}

__________________
Spirit_12 is offline
Facksy
Senior Member
Join Date: Apr 2017
Location: +2+2
Old 04-23-2018 , 06:52   Re: KeyValues error
Reply With Quote #3

Even with these changes it doesnt worj
Facksy is offline
Facksy
Senior Member
Join Date: Apr 2017
Location: +2+2
Old 04-23-2018 , 06:59   Re: KeyValues error
Reply With Quote #4

Alright, i fixed, strangely it was this part which is supposed to be a comment:
HTML Code:
**
 * USE THIS SECTION TO DECLARE DETAILED ADMIN PROPERTIES.
 *
 * Each admin should have its own "Admin" section, followed by a name.
 * The name does not have to be unique.
 *
 * Available properties: (Anything else is filtered as custom)
 *      "auth"          - REQUIRED - Auth method to use.  Built-in methods are:
 *                        "steam"  - Steam based authentication
 *                        "name"   - Name based authentication
 *                        "ip"	- IP based authentication
 *                        Anything else is treated as custom.
 *					 Note: Only one auth method is allowed per entry.
 *
 *      "identity"      - REQUIRED - Identification string, for example, a steamid or name.
 *					 Note: Only one identity is allowed per entry.
 *
 *      "password"      - Optional password to require.
 *      "group"         - Adds one group to the user's group table.
 *      "flags"         - Adds one or more flags to the user's permissions.
 *		"immunity"		- Sets the user's immunity level (0 = no immunity).
 *						  Immunity can be any value.  Admins with higher 
 *						  values cannot be targetted.  See sm_immunity_mode 
 *						  to tweak the rules.  Default value is 0.
 *
 * Example:
	"BAILOPAN"
	{
		"auth"			"steam"
		"identity"		"STEAM_0:1:16"
		"flags"			"abcdef"
	}
 *
 */
When i remove it, it doesnt reply any errors
Facksy is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 04-23-2018 , 11:37   Re: KeyValues error
Reply With Quote #5

You can't have multiline comments in KeyValues.
Fyren is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 04-23-2018 , 18:42   Re: KeyValues error
Reply With Quote #6

If you want to parse a Sourcemod config file with a custom plugin (and keep multiline comments), you'll probably need to use SMCParser rather than KeyValues.

Good luck though, there's almost zero documentation that I've found.
__________________

Last edited by ddhoward; 04-23-2018 at 18:43.
ddhoward is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-23-2018 , 19:27   Re: KeyValues error
Reply With Quote #7

Quote:
Originally Posted by ddhoward View Post
If you want to parse a Sourcemod config file with a custom plugin (and keep multiline comments), you'll probably need to use SMCParser rather than KeyValues.

Good luck though, there's almost zero documentation that I've found.
SMCParser doesn't get used a lot because it's literally a library for writing the equivalent of the API KeyValues already gives you.

In other words, it's a lot of extra work for very little benefit.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 04-23-2018 , 22:56   Re: KeyValues error
Reply With Quote #8

Quote:
Originally Posted by Powerlord View Post
In other words, it's a lot of extra work for very little benefit.
SMC is better when you don't want to deal with the bugs, slowness, and limitations of Valve's KV implementation.

Quote:
Originally Posted by ddhoward View Post
Good luck though, there's almost zero documentation that I've found.
SMC is basically a SAX-style parser as opposed to DOM. You get callbacks as the input is walked through. The header is pretty short to read through and there are examples of usage in the base SM plugins.
Fyren 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:52.


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