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_SM, filePath, sizeof(filePath), "configs/SpirT/VIP-Tags/tags.cfg");
}
public void OnClientAuthorized(int client, const char[] auth)
{
GetClientAuthId(client, AuthId_Steam2, authID[client], sizeof(authID[]));
WaitingForScoreboardTag[client] = false;
CheckForKeyValues(client, authID[client]);
FetchCookieInfo(client);
}
void CheckForKeyValues(int client, char[] steamID)
{
KeyValues kv = new KeyValues("VIPTags");
kv.ImportFromFile(filePath);
KvGotoFirstSubKey(kv);
if(!kv.JumpToKey(steamID, true))
{
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:
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?
__________________