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

Solved KeyValues not working


Post New Thread Reply   
 
Thread Tools Display Modes
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 02-24-2021 , 08:37   Re: KeyValues not working
Reply With Quote #11

Quote:
Originally Posted by DJ Tsunami View Post
I don't know, works fine for me:
PHP Code:
char filePath[PLATFORM_MAX_PATH 1];
char scoreTag[MAXPLAYERS 1][64];
char chatColor[MAXPLAYERS 1][64];
char nameColor[MAXPLAYERS 1][64];

public 
void OnPluginStart()
{
    
BuildPath(Path_SMfilePathsizeof(filePath), "configs/viptags.cfg");

    
CheckForKeyValues(1"STEAM_0:1:2");
}

void CheckForKeyValues(int clientchar[] steamID)
{
    
KeyValues kv = new KeyValues("VIPTags");
    
kv.ImportFromFile(filePath);
    
kv.JumpToKey(steamIDtrue);

    
kv.GetString("scoretag"scoreTag[client], sizeof(scoreTag[]));
    
kv.GetString("chatcolor"chatColor[client], sizeof(chatColor[]));
    
kv.GetString("namecolor"nameColor[client], sizeof(nameColor[]));

    if (
StrEqual(scoreTag[client], "") && StrEqual(chatColor[client], "") && StrEqual(nameColor[client], ""))
    {
        
kv.SetString("scoretag""-change-");
        
kv.SetString("chatcolor""-change-");
        
kv.SetString("namecolor""-change-");
        
kv.Rewind();
        
kv.ExportToFile(filePath);
    }

    
delete kv;

Output:
Code:
"VIPTags"
{
	"STEAM_0:1:2"
	{
		"scoretag"		"-change-"
		"chatcolor"		"-change-"
		"namecolor"		"-change-"
	}
}
Found another little issue.

PHP Code:
void SetNewScoreboardTag(int client, const char[] newTag)
{
    
strcopy(scoreTag[client], sizeof(scoreTag[]), newTag);
    
CS_SetClientClanTag(clientscoreTag[client]);
    
KeyValues kv = new KeyValues("VIPTags");
    
kv.ImportFromFile(filePath);
    if(
kv.JumpToKey(authID[client], false))
    {
        
KvSetString(kv"scoretag"scoreTag[client]);
        
kv.Rewind();
        
kv.ExportToFile(filePath);
        
delete kv;
        return;
    }
    
    
delete kv;
    return;

The line is being written like this:
Code:
"VIPTags"
{
	"STEAM_0:1:2"
	{
		"scoretag"		"-change-"
		"chatcolor"		"-change-"
		"namecolor"		"-change-"
	}
	"STEAM_1:1:419435558"
	{
		"scoretag"		"-change-"
		"chatcolor"		"-change-"
		"namecolor"		"-change-"
	}
	"scoretag"		"[SCORE] "
        "chatcolor"		"-change-"
	"namecolor"		"-change-"
}
Any idea?
__________________

Last edited by SpirT; 02-24-2021 at 08:39.
SpirT is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-24-2021 , 09:32   Re: KeyValues not working
Reply With Quote #12

Are you 100% sure, you have something in string array ? I guess it's empty string "" while you reload plugin or else...

Also, you not create new section https://sm.alliedmods.net/new-api/ke...lues/JumpToKey nvm
Code:
if(kv.JumpToKey(authID[client], false))

Last edited by Bacardi; 02-24-2021 at 09:35. Reason: nvm
Bacardi is offline
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 02-24-2021 , 10:00   Re: KeyValues not working
Reply With Quote #13

Quote:
Originally Posted by Bacardi View Post
Are you 100% sure, you have something in string array ? I guess it's empty string "" while you reload plugin or else...

Also, you not create new section https://sm.alliedmods.net/new-api/ke...lues/JumpToKey nvm
Code:
if(kv.JumpToKey(authID[client], false))
You're right, my bad! I did a loop for players and now it is getting everyone's steamID.
__________________
SpirT 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 00:49.


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