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

Solved FileToKeyValues always return false


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
blackdevil72
Member
Join Date: Jun 2010
Location: Bordeaux (France)
Old 05-12-2019 , 01:21   FileToKeyValues always return false
Reply With Quote #1

Hello,

I'm confronted to a problem, I'm trying to parse config file with KeyValues but each times I'm running a file through it FileToKeyValues return false. The path to the file is correct, the file exist the Keyvalue exist in the file. I'm out of idea on what is going wrong.

Thanks to any one who can help me.

Here is my code:

PHP Code:
public bool Hns_Models_LoadModels()
{
    
Global_TotalModels 0

    Handle Kv_Models 
CreateKeyValues("Models")

    
char CurrentMap[PLATFORM_MAX_PATH]
    
GetCurrentMap(CurrentMapsizeof(CurrentMap))
    
    
char ConfigFilePath[PLATFORM_MAX_PATH]
    
BuildPath(Path_SMConfigFilePathsizeof(ConfigFilePath), "configs/HideAndSeek/maps/%s.cfg"CurrentMap)

    
char ModelsPath[PLATFORM_MAX_PATH]
    
char ModelsCachedPath[PLATFORM_MAX_PATH]

    if (
FileToKeyValues(Kv_ModelsConfigFilePath) == false)
    {
        
Global_ModelsLoaded false
        PrintToServer
("[SM][HnS] Can't parse Models config file for map %s."CurrentMap)
        
CloseHandle(Kv_Models)

        return 
false
    
}

    else
    {
        
KvGotoFirstSubKey(Kv_Models)

        do
        {
            
// Get Models Path And Precache It
            
KvGetSectionName(Kv_ModelsModelsPathsizeof(ModelsPath))
            
Format(ModelsCachedPathsizeof(ModelsCachedPath), "models/%s.mdl"ModelsPath)
            
PrecacheModel(ModelsCachedPathtrue)

            
Global_TotalModels++
        }
        while (
KvGotoNextKey(Kv_Models))

        
Global_ModelsLoaded true
        CloseHandle
(Kv_Models)

        return 
true
    
}

__________________


Last edited by blackdevil72; 05-13-2019 at 23:21.
blackdevil72 is offline
CrazyHackGUT
AlliedModders Donor
Join Date: Feb 2016
Location: Izhevsk, Russia
Old 05-12-2019 , 03:33   Re: FileToKeyValues always return false
Reply With Quote #2

Show your file. Maybe syntax error, and you don't see this.
__________________
My english is very bad. I am live in Russia. Learning english language - very hard task for me...
CrazyHackGUT is offline
Send a message via ICQ to CrazyHackGUT Send a message via Skype™ to CrazyHackGUT
blackdevil72
Member
Join Date: Jun 2010
Location: Bordeaux (France)
Old 05-12-2019 , 03:40   Re: FileToKeyValues always return false
Reply With Quote #3

Oh yeas sorry I forgot that. Here it is.

For each maps they are all structured the same way.
Attached Files
File Type: cfg de_dust2.cfg (1.1 KB, 55 views)
__________________

blackdevil72 is offline
blackdevil72
Member
Join Date: Jun 2010
Location: Bordeaux (France)
Old 05-13-2019 , 07:45   Re: FileToKeyValues always return false
Reply With Quote #4

Does any one have any of what I did wrong? I have and other function I wrote for an other part of the plug in that have the exact same problem.
__________________

blackdevil72 is offline
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 05-13-2019 , 10:16   Re: FileToKeyValues always return false
Reply With Quote #5

Your code runs fine on my server. Are you sure your user has sufficient permissions to the HideAndSeek directory, and it's files?

Last edited by Kolapsicle; 05-13-2019 at 11:29.
Kolapsicle is offline
blackdevil72
Member
Join Date: Jun 2010
Location: Bordeaux (France)
Old 05-13-2019 , 19:06   Re: FileToKeyValues always return false
Reply With Quote #6

For me it doesn't work locally. I'm running Arch Linux as my primary os, I tried with a chmod of 750, then 770, and finish with 777 its didn't work and the owner is my user so I don't know what is happening
.
I also tried on my remote server and same thing is happening. I don't have any way to try on a Windows or Mac SRCDS install.

To make things easier if the problem come from elsewhere here is the GitHub of the project: https://github.com/blackdevil72/HideAndSeek2

EDIT:

I've found a work around, if I rename the folder to "hideandseek" and not "HideAndSeek" it works. On what OS did you ti run my code please? Can some one else could try on and other Linux distrib and on Windows? maybe on Mac is some one can do that.
__________________


Last edited by blackdevil72; 05-13-2019 at 20:06.
blackdevil72 is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 05-13-2019 , 20:34   Re: FileToKeyValues always return false
Reply With Quote #7

Quote:
Originally Posted by blackdevil72 View Post
I've found a work around, if I rename the folder to "hideandseek" and not "HideAndSeek" it works. On what OS did you ti run my code please? Can some one else could try on and other Linux distrib and on Windows? maybe on Mac is some one can do that.
Linux filesystems differentiate between "hideandseek" vs "HideAndSeek". On Windows and Mac this is not true. For this reason it is always recommended to leave all directories lowercase.

I'm not quite sure what is causing this issue, however it could just be how the game is deciding to load the file. It doesn't seem like SourceMod itself modifies the file path input in any way.

Last edited by headline; 05-13-2019 at 20:34.
headline is offline
blackdevil72
Member
Join Date: Jun 2010
Location: Bordeaux (France)
Old 05-13-2019 , 23:21   Re: FileToKeyValues always return false
Reply With Quote #8

Yes linux is case sensitive, I suposed it was or coming from the source engine way to handle files or sourcemod/sourceapawn.

My best guess is it come from the source engine, it date from a period pre valve interest for linux, its possible as it was first intended for windows support that there file management is a bit "dirty". That would also explain some error I have in the ingame consoles that don't appear on windows when loading some maps.

Thank you I'll put that resolved then.
__________________

blackdevil72 is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-14-2019 , 16:52   Re: FileToKeyValues always return false
Reply With Quote #9

FileToKeyValues is a wrapper around a SDK function so uses the engine's filesystem interface, which does indeed lowercase all paths on most games.
__________________
asherkin 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 15:15.


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