Raised This Month: $77 Target: $400
 19% 

Plugin unable to find key value


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ThefatDaddy
Junior Member
Join Date: Nov 2015
Old 04-13-2019 , 11:05   Plugin unable to find key value
Reply With Quote #1

I am trying to use a plugin to force skins by steamid and it keeps coming back with the following error:


PHP Code:
L 04/13/2019 10:48:45: [forced_skin.smxOpening key value file to check for [CSGCTheFatDaddy<5><[U:1:xxxxx]><>
L 04/13/2019 10:48:45: [forced_skin.smxNo skin defined for for [CSGCTheFatDaddy<5><[U:1:xxxxx]><> 
forced_skin.txt - located in cstrike/addons/sourcemod/configs. The skin is in the correct directory, works with skinchooser (I just want something tied to steamid) and is in my client files.

PHP Code:
"Forced Skin"

{
    
"[U:1:xxxxx]"
    
{
        
"path" "models/player/csgc/bobafett/b4p_bobafett.mdl”
    }

Plugin source

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define _DEBUG        1    // Set to 1 to have debug spew

#define PLUGIN_VERSION    "0.0.1.0"

new String:kv_file[PLATFORM_MAX_PATH];

new 
bool:Enabled false;
new 
bool:PlayerHasForcedSkin[MAXPLAYERS 1] = {false, ...};
new 
String:ForcedSkin[MAXPLAYERS 1][PLATFORM_MAX_PATH];

new 
Handle:ClientTimer[MAXPLAYERS 1] = {INVALID_HANDLE, ...};

public 
Plugin:myinfo 
{
    
name "Forced Skin",
    
author "TnTSCS aKa ClarkKent",
    
description "Force players to have certain defined skin",
    
version PLUGIN_VERSION,
    
url "https://forums.alliedmods.net"
}

public 
OnPluginStart()
{
    new 
Handle:hRandom// KyleS hates handles
    
    
HookConVarChange((hRandom CreateConVar("sm_fs_version"PLUGIN_VERSION
    
"The version of 'Forced Skin'"FCVAR_SPONLY FCVAR_REPLICATED FCVAR_NOTIFY FCVAR_PLUGIN FCVAR_DONTRECORD)), OnVersionChanged);
    
    
HookConVarChange((hRandom CreateConVar("sm_fs_enabled""1"
    
"Is Forced Skin enabled?"FCVAR_NONEtrue0.0true1.0)), OnEnabledChanged);
    
Enabled GetConVarBool(hRandom);
    
    
CloseHandle(hRandom);
    
    
BuildPath(Path_SMkv_filePLATFORM_MAX_PATH"configs/forced_skin.txt");
    
    
HookEvent("player_spawn"Event_PlayerSpawn);
}

public 
OnClientAuthorized(client, const String:auth[])
{
    if (
Enabled && client != && !IsFakeClient(client))
    {
        
ForcedSkin[client][0] = '\0';
        
        if (
ClientHasAssignedSkin(clientauth))
        {
            
PlayerHasForcedSkin[client] = true;
        }
        else
        {
            
PlayerHasForcedSkin[client] = false;
        }
    }
}

public 
OnClientDisconnect(client)
{
    if (
IsClientConnected(client))
    {
        
PlayerHasForcedSkin[client] = false;
        
        
ForcedSkin[client][0] = '\0';
        
        
ClearTimer(ClientTimer[client]);
    }
}

public 
Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
    if (!
Enabled || client || client MaxClients || !PlayerHasForcedSkin[client])
    {
        return;
    }
    
    
// Timer to set skin
    
if (IsModelPrecached(ForcedSkin[client]))
    {
        
ClientTimer[client] = CreateTimer(0.1Timer_ApplySkinclient);
    }
    else
    {
        
LogError("Model for %L (%s) is not precached!!!"clientForcedSkin[client]);
        
PrintToChat(client"\x03There's a problem with your model, let an admin know");
        
PrintToChat(client"Your assigned model: \x02%s"ForcedSkin[client]);
    }
}

public 
Action:Timer_ApplySkin(Handle:timerany:client)
{
    
ClientTimer[client] = INVALID_HANDLE;
    
    
SetEntityModel(clientForcedSkin[client]);
}

bool:ClientHasAssignedSkin(client, const String:auth[])
{
    new 
Handle:kv CreateKeyValues("Forced Skins");
    
    if (!
FileToKeyValues(kvkv_file))
    {
        
SetFailState("Unable to open file %s"kv_file);
    }
    
    
#if _DEBUG
        
LogMessage("Opening key value file to check for %L"client);
    
#endif
    
    
if (!KvGotoFirstSubKey(kv))
    {
        
#if _DEBUG
            
LogMessage("Unable to find any keys in the key value file");
        
#endif
        
        
return false;
    }
    
    
decl String:model[PLATFORM_MAX_PATH];
    
model[0] = '\0';
    
    
decl String:steamid[50];
    
steamid[0] = '\0';
    
    do
    {
        
KvGetSectionName(kvsteamidsizeof(steamid));
        
        if (
StrEqual(steamidauth))
        {
            
KvGetString(kv"path"modelsizeof(model));
            
            
TrimString(model);
            
            
#if _DEBUG
                
LogMessage("Setting %s for %L."modelclient);
            
#endif
            
            
Format(ForcedSkin[client], sizeof(ForcedSkin[]), model);
            
            
CloseHandle(kv);
            
            return 
true;
        }
    } while (
KvGotoNextKey(kv));
    
    
CloseHandle(kv);
    
    
#if _DEBUG
        
LogMessage("No skin defined for for %L"client);
    
#endif
    
    
return false;
}

public 
ClearTimer(&Handle:timer)
{
    if (
timer != INVALID_HANDLE)
    {
        
KillTimer(timer);
        
timer INVALID_HANDLE;
    }     
}

public 
OnVersionChanged(Handle:cvar, const String:oldValue[], const String:newValue[])
{
    if (!
StrEqual(newValuePLUGIN_VERSION))
    {
        
SetConVarString(cvarPLUGIN_VERSION);
    }
}

public 
OnEnabledChanged(Handle:cvar, const String:oldValue[], const String:newValue[])
{
    
Enabled GetConVarBool(cvar);


Last edited by ThefatDaddy; 04-13-2019 at 11:10. Reason: clarification
ThefatDaddy is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-13-2019 , 17:11   Re: Plugin unable to find key value
Reply With Quote #2

Have you tried printing the value of auth to make sure it's the same Steam ID type?

If it isn't, you might want to get GetClientAuthId to make sure you get the right type, which appears to be AuthId_Steam3 in your example.
__________________
Am I back? Well, we'll see.
Powerlord is offline
ThefatDaddy
Junior Member
Join Date: Nov 2015
Old 04-13-2019 , 17:59   Re: Plugin unable to find key value
Reply With Quote #3

Thank you! I will try and let you know.
ThefatDaddy is offline
ThefatDaddy
Junior Member
Join Date: Nov 2015
Old 04-14-2019 , 22:10   Re: Plugin unable to find key value
Reply With Quote #4

Everything works! I am using both this for dedicated steamid driven skins and sm_skinchooser for bots, precaching and downloads. They seem to work well together.

Last edited by ThefatDaddy; 04-14-2019 at 22:10.
ThefatDaddy is offline
Reply


Thread Tools
Display Modes

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 20:40.


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