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

PrecacheTables


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wtfaatp
Senior Member
Join Date: Jul 2010
Old 05-19-2014 , 10:51   PrecacheTables
Reply With Quote #1

So anyone tell me why this isn't working? PLEASE


Code:
stock AddFolderToPrecacheTables(const String:Directory[], bool:random = false) 
{
    decl String:FileName[64], String:Path[512];
    new Handle:Dir = OpenDirectory(Directory), FileType:Type;
    while(ReadDirEntry(Dir, FileName, sizeof(FileName), Type))
    {
        if(Type == FileType_Directory)
        {
            Format(FileName, sizeof(FileName), "%s/%s", Directory, FileName);
            AddFolderToPrecacheTables(FileName);
            continue;
        }
        if (Type != FileType_File)
        {
            continue;
        }
        Format(Path, sizeof(Path), "%s/%s", Directory, FileName);
        PrecacheSound(Path);
        
        if (random) PushArrayString(g_hArray_Random, Path);
        
        Format(Path, sizeof(Path), "sound/%s/%s", Directory, FileName);
        AddFileToDownloadsTable(Path);
    }
}
__________________
SourceMod : 1.10.0 (Official) | MetaMod : 1.10.7 (Official)
Server : NFOservers - Windows

Last edited by wtfaatp; 05-19-2014 at 10:51.
wtfaatp is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 05-19-2014 , 13:00   Re: PrecacheTables
Reply With Quote #2

Are you sure this
PHP Code:
new Handle:Dir OpenDirectory(Directory), FileType:Type
working as you think it is? Extra line won't hurt and looks much cleaner.

Also you are putting both directory and filename into the Filename[64] which is might be too small. There is a PLATFORM_MAX_PATH constant just for that.

And i would check what you are actually getting from ReadDirEntry, maybe it returns extra / or something.

And the last one. Are you sure you are passing the full path in function? I guess the idea was: you have a folder structure something like this:
Code:
sound/
          myubersounds/
                             funsounds/
                             music/
                             vote/
And passing AddFolderToPrecacheTables("sound/myubersounds") will precache all the sounds.
But when it comes to second iteration, it will pass the AddFolderToPrecacheTables("myubersounds/ololo.mp3") and then AddFolderToPrecacheTables("music/ululung.mp3"). I hope you get the idea. I don't think you are keeping the folder structure. You are using only the last folder in chain. But you need the full path for precache function to work.
xf117 is offline
Send a message via ICQ to xf117
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 05-19-2014 , 14:33   Re: PrecacheTables
Reply With Quote #3

You have the sound files installed on the server in the same paths, right? Usually, custom sound files (or, really, all sound files...) aren't required to be on the server, but they need to be in order for that function to work.
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)
MasterOfTheXP 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 18:21.


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