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

KeyValues, how I can get current KeyValue key name?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iGANGNAM
AlliedModders Donor
Join Date: Sep 2012
Location: Lithuania
Old 07-05-2016 , 18:35   KeyValues, how I can get current KeyValue key name?
Reply With Quote #1

Code:
"root"
{
	"cvars"
	{
		"status"		"success"
		"pre-warmup"
		{
			"sv_disable_show_team_select_menu"		"0"
			"mp_roundtime"		"5.0"
			"sv_talk_enemy_living"		"1"
			"sv_talk_enemy_dead "		"1"
		}
		"post-warmup"
		{
			"sv_talk_enemy_living"		"1"
			"sv_talk_enemy_dead "		"1"
		}
	}
}
.........................
Code:
	kv.GotoFirstSubKey(false);
	do {
		kv.GetString(NULL_STRING, temp_string2, PLATFORM_MAX_PATH);
		kv.GetSectionSymbol(temp_id);
		kv.GetNameSymbol(temp_id, temp_string, PLATFORM_MAX_PATH);
		#if defined DEBUG
		#endif
		FindConVar(temp_string);
		if (hndl == null) {
			LogError("Cvar not found. ID: %d, Cvar: %s", temp_string, temp_string2);
		} else {
			hndl.SetString(temp_string2, true);
			#if defined DEBUG
			LogMessage("CVAR: %s %s", temp_string, temp_string2);
			#endif
		}
		
	} while (kv.GotoNextKey(false));
.............
Code:
L 07/05/2016 - 18:25:02: [plugin.smx] Cvar not found. Cvar: 0, Value: 0
L 07/05/2016 - 18:25:02: [plugin.smx] Cvar not found. Cvar: 0, Value: 5.0
L 07/05/2016 - 18:25:02: [plugin.smx] Cvar not found. Cvar: 0, Value: 1
L 07/05/2016 - 18:25:02: [plugin.smx] Cvar not found. Cvar: 0, Value: 1
__________________

Last edited by iGANGNAM; 07-05-2016 at 18:57.
iGANGNAM is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-05-2016 , 18:41   Re: KeyValues, how I can get current KeyValue key name?
Reply With Quote #2

kv.GetSectionName should give you the key name.

I know that's confusing as you'd think it would give you the name of the section the current keyvalue is in.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 07-05-2016 at 18:42.
Powerlord is offline
iGANGNAM
AlliedModders Donor
Join Date: Sep 2012
Location: Lithuania
Old 07-05-2016 , 18:43   Re: KeyValues, how I can get current KeyValue key name?
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
kv.GetSectionName should give you the key name.

I know that's confusing as you'd think it would give you the name of the section the current keyvalue is in.
I remember it came out with random numbers but I guess I can try it again.
__________________

Last edited by iGANGNAM; 07-05-2016 at 18:43.
iGANGNAM is offline
iGANGNAM
AlliedModders Donor
Join Date: Sep 2012
Location: Lithuania
Old 07-05-2016 , 18:47   Re: KeyValues, how I can get current KeyValue key name?
Reply With Quote #4

Yeah It's like I said
Code:
L 07/05/2016 - 18:47:09: [plugin.smx] Cvar not found. Cvar Name: 1918857325, Cvar Value: 5.0
L 07/05/2016 - 18:47:09: [plugin.smx] Cvar not found. Cvar Name: 1952413299, Cvar Value: 1
L 07/05/2016 - 18:47:09: [plugin.smx] Cvar not found. Cvar Name: 1952413299, Cvar Value: 1
L 07/05/2016 - 18:47:09: [plugin.smx] Cvar not found. Cvar Name: 1683977843, Cvar Value: 0
__________________

Last edited by iGANGNAM; 07-05-2016 at 18:56.
iGANGNAM is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 07-05-2016 , 19:11   Re: KeyValues, how I can get current KeyValue key name?
Reply With Quote #5

Quote:
Originally Posted by iGANGNAM View Post
Yeah It's like I said
Code:
L 07/05/2016 - 18:47:09: [plugin.smx] Cvar not found. Cvar Name: 1918857325, Cvar Value: 5.0
L 07/05/2016 - 18:47:09: [plugin.smx] Cvar not found. Cvar Name: 1952413299, Cvar Value: 1
L 07/05/2016 - 18:47:09: [plugin.smx] Cvar not found. Cvar Name: 1952413299, Cvar Value: 1
L 07/05/2016 - 18:47:09: [plugin.smx] Cvar not found. Cvar Name: 1683977843, Cvar Value: 0
This is because you're doing:

PHP Code:
LogError("Cvar not found. ID: %d, Cvar: %s"temp_stringtemp_string2); 
1918857325 == 0x725F706D

Reverse the bytes in the hex to get 0x6D705F72. As ASCII, "mp_r", or the first four bytes of your string. Because you're printing it as an integer.
Fyren is offline
iGANGNAM
AlliedModders Donor
Join Date: Sep 2012
Location: Lithuania
Old 07-05-2016 , 19:15   Re: KeyValues, how I can get current KeyValue key name?
Reply With Quote #6

Quote:
Originally Posted by Fyren View Post
This is because you're doing:

PHP Code:
LogError("Cvar not found. ID: %d, Cvar: %s"temp_stringtemp_string2); 
1918857325 == 0x725F706D

Reverse the bytes in the hex to get 0x6D705F72. As ASCII, "mp_r", or the first four bytes of your string. Because you're printing it as an integer.
Thank you for noticing, now I fixed all issues
__________________
iGANGNAM 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 23:20.


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