AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help with file functions (https://forums.alliedmods.net/showthread.php?t=88045)

Emp` 03-19-2009 16:55

help with file functions
 
Here's some functions I created: http://ampaste.net/m250325bd

They produce the correct file: http://ampaste.net/m7f2e4e3f

However, file_get_data does not seem to work correctly, anyone see something wrong with it?

Emp` 03-19-2009 20:27

Re: help with file functions
 
Fyi the fix was:
Code:

file_get_data(const filename[], const key[], const name[], data[], len, const identifier=';')
 {
        new f = fopen(filename, "rt");

        new bool:found_key = false;
        new _data[512], _name[64], _other[2];
       
        if( equal(key, EMPTY) )
                found_key = true;

        while( !feof(f) )
        {
                fgets(f, _data, sizeof(_data) - 1);

                if( _data[0] == identifier ){
                        if( found_key ){
                                break;
                        }
                        else{
                                parse(_data[1], _name, sizeof(_name) - 1, _other, sizeof(_other) - 1);
                                if( equal( key, _name ) )
                                        found_key = true;
                        }
                }
                else{
                        parse(_data, _name, sizeof(_name) - 1, data, len);
                        if( found_key ){
                                if( equal(_name, name) || equal( name, STAR ) ){
                                        fclose(f);
                                        return 1;
                                }
                        }
                }
        }
       
        fclose(f);
        ClearStr(data);
        return 0;
 }



All times are GMT -4. The time now is 08:52.

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