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

Solved KeyValues not working


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 02-24-2021 , 03:50   KeyValues not working
Reply With Quote #1

Hey.

I've been building a plugin where it needs to check on client authorized if his steamid is on the file as keyvalues. It is suposed to create one if it doesn't exist.

Current code part where I want to create it:
PHP Code:
char authID[MAXPLAYERS 1][32];
char scoreTag[MAXPLAYERS 1][16];
char chatColor[MAXPLAYERS 1][16];
char nameColor[MAXPLAYERS 1][16];
char filePath[256];

public 
void OnPluginStart()
{
    
BuildPath(Path_SMfilePathsizeof(filePath), "configs/SpirT/VIP-Tags/tags.cfg");
}

public 
void OnClientAuthorized(int client, const char[] auth)
{
    
GetClientAuthId(clientAuthId_Steam2authID[client], sizeof(authID[]));
    
WaitingForScoreboardTag[client] = false;
    
CheckForKeyValues(clientauthID[client]);
    
FetchCookieInfo(client);
}

void CheckForKeyValues(int clientchar[] steamID)
{
    
KeyValues kv = new KeyValues("VIPTags");
    
kv.ImportFromFile(filePath);
    
    
KvGotoFirstSubKey(kv);
    
    if(!
kv.JumpToKey(steamIDtrue))
    {
        
PrintToServer("Couldn't find a key for %s but we'll try to create it."steamID);
        
KvSetString(kv"scoretag""Teste - ");
        
KvSetString(kv"chatcolor""{red}");
        
KvSetString(kv"namecolor""{blue}");
        
kv.ExportToFile(filePath);
        
delete kv;
        return;
    }
    else
    {
        
PrintToServer("FOUND A FCKNG KEY FOR: %s."steamID);
        
KvGetString(kv"scoretag"scoreTag[client], sizeof(scoreTag[]));
        
KvGetString(kv"chatcolor"chatColor[client], sizeof(chatColor[]));
        
KvGetString(kv"namecolor"nameColor[client], sizeof(nameColor[]));
        
delete kv;
        return;
    }

When I connect or when I use !check (to execute the void CheckForKeyValues) it always send to the console that found the key when it doesn't exist

Current tags.cfg content:
Code:
"VIPTags"
{
	
}
If I type my steam there it does work and it gets the variables that I have typed there. How can I make the plugin to create the key itself?
__________________

Last edited by SpirT; 02-24-2021 at 07:41.
SpirT is offline
 



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:55.


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