AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Download Prob! (https://forums.alliedmods.net/showthread.php?t=91612)

andi67 05-03-2009 05:36

Download Prob!
 
I got a little bit of trouble with files to download.
The readfile doesn´t seems to work cause there is only one file downloaded by file.
Any suggestions how about to fix this?

Code:

public OnMapStart()
{
    new String:file[256];
    BuildPath(Path_SM, file, 255, "configs/downloads.ini");
    new Handle:fileh = OpenFile(file, "r");
    new String:buffer[256];
    while (ReadFileLine(fileh, buffer, sizeof(buffer)))
    {
        new len = strlen(buffer)
        if (buffer[len-1] == '\n')
            buffer[--len] = '\0';
        if (FileExists(buffer))
        {
            AddFileToDownloadsTable(buffer);
        }
        if (IsEndOfFile(fileh))
            break;
    }
 
    for (new i = 0; i < 6; i++)
    {
        PrecacheModel(g_modelAmerName[i], true);
        PrecacheModel(g_modelAxisName[i], true);
    }
}


Cooltad 05-03-2009 06:11

Re: Download Prob!
 
https://forums.alliedmods.net/showthread.php?t=91492

That should give you some insight to making something download and precache.

andi67 05-03-2009 07:29

Re: Download Prob!
 
Nice one but that was not my question.
Nevermind THX to you.

Fredd 05-05-2009 03:46

Re: Download Prob!
 
andi67@: i use something similar which just adds everything to the downloadables table and precaches mdl files...
Code:

public OnMapStart()
{
        decl String:File[260]; // max platform path for win i think.
        BuildPath(Path_SM, File, sizeof(File), "blah/blah/downloads.ini");
        new Handle:FileHndl = OpenFile(File, "r");
        decl String:buffer[260];
        while (ReadFileLine(FileHndl, buffer, sizeof(buffer)))
        {
                new len = strlen(buffer);
                if(buffer[len-1] == '\n')
                        buffer[--len] = '\0';
               
                if (FileExists(buffer))
                {
                        AddFileToDownloadsTable(buffer);
                       
                        if(StrEqual(buffer[len-3], "mdl"))
                                PrecacheModel(buffer, true);
                }
               
                if (IsEndOfFile(FileHndl))
                {
                        CloseHandle(FileHndl);       
                        break;
                }
        }
}

just put everything int that ini file..

andi67 05-05-2009 05:49

Re: Download Prob!
 
THX , I will check this out.

andi67 05-05-2009 17:10

Re: Download Prob!
 
doesn´t work , still the same as in first post.
:(

Fredd 05-05-2009 17:33

Re: Download Prob!
 
paste ur downloads.ini

andi67 05-06-2009 03:17

Re: Download Prob!
 
1 Attachment(s)
THX

I got this error :

L 05/05/2009 - 22:50:43: [SM] Native "ReadFileLine" reported: Invalid file handle 0 (error 4)

Fredd 05-06-2009 19:50

Re: Download Prob!
 
That's weird it works fine here, make sure it's pointing to the right file path.

naris 05-06-2009 20:11

Re: Download Prob!
 
Quote:

Originally Posted by andi67 (Post 822086)
L 05/05/2009 - 22:50:43: [SM] Native "ReadFileLine" reported: Invalid file handle 0 (error 4)

The open failed. Make sure the downloads.ini file is indeed in the location it is supposed to be in.


All times are GMT -4. The time now is 20:14.

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