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

could use some help with keyvalues


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SimonTheOne
Member
Join Date: Apr 2010
Old 05-11-2010 , 07:22   could use some help with keyvalues
Reply With Quote #1

hey this is my first time working with keyvalues and its not working..

i need it to write a new section with the client's steamid but it doesn't

here's the code:
Code:
public OnClientAuthorized(client)
{
	if (!FileExists(Path))
	{
		return;
	}
	
	GetClientAuthString(client, SteamID, sizeof(SteamID));
	
	decl Handle:kv;
	kv = CreateKeyValues("kills");
	FileToKeyValues(kv, Path);
	
	if (!KvJumpToKey(kv, SteamID, true))
	{
		CloseHandle(kv);
		return;
	}
	CloseHandle(kv);
}
this is how my i want my file to look:

Code:
"kills"
{
	"STEAM_0:0:1"
	{
		"killcount"	"1"
	}
}
any help would be much appreciated
SimonTheOne is offline
HL-SDK
Member
Join Date: Jan 2009
Old 05-11-2010 , 14:44   Re: could use some help with keyvalues
Reply With Quote #2

Hi, I don't think you're writign the key anywhere.

In the
if (!KvJumpToKey(kv, SteamID, true))
block, you should create the key if it doesn't exist, ELSE update the current value.

At least I think so.
HL-SDK is offline
SimonTheOne
Member
Join Date: Apr 2010
Old 05-13-2010 , 16:17   Re: could use some help with keyvalues
Reply With Quote #3

i figured it out, thanks
SimonTheOne is offline
Master53
Veteran Member
Join Date: Dec 2009
Old 05-13-2010 , 17:10   Re: could use some help with keyvalues
Reply With Quote #4

i can give you a basic layout from one of my plugins. you will need to modify this tho to get it working.


GetClientAuthString(Client, SteamId, 32);
Vault = CreateKeyValues("Vault");
FileToKeyValues(Vault, DoorPath);

//load number of doors owned
for(new X = 0; X < MAXDOORS; X++)
{
IntToString(X, Key, 32);

KvJumpToKey(Vault, Key, false);
temp = KvGetNum(Vault, SteamId, 0);
KvRewind(Vault);
}
CloseHandle(Vault);

//load number of props spawned
Vault = CreateKeyValues("Vault");
FileToKeyValues(Vault, PropPath);
KvJumpToKey(Vault, "props", false);
temp = KvGetNum(Vault, SteamId, 0);
propsSpawned[Client] = temp;
CloseHandle(Vault);

//this is how i would save the values
//Map Start:
public OnMapStart()
{
BuildPath(Path_SM, DoorPath, 64, "data/roleplay/doors.txt");
if(FileExists(DoorPath) == false) PrintToConsole(0, "[SM] ERROR: Missing file '%s'", DoorPath);
}
Master53 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 22:51.


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