Load All .ini file with dini?
#1

hey there i have a question how to load all .ini file in 1 folder using dini

like this :

Quote:

label1.ini
label2.ini
label3.ini
label4.ini

it saved on label folder and how to load that file i mean load label1.ini till label4.ini(all file in label folder) using dini
anyone know how?
Reply
#2

PHP код:
stock LoadLabels()
{
    new 
bool:Finished;
    for(new 
i=0; !Finishedi++)
    {
        new 
string[60];
        
format(stringsizeof(string), "/label/label%d.ini"i);
        if(
fexist(string))
        {
             
//load it here
             
dini_Int...blah..blah..blah
        
}
        else
        {
             
Finished=true;
        }
    }

Reply
#3

Don't use dini...it's outdated, unsupported, and one of the slowest methods available. SQL would be ideal for what you are trying to do. Try using SQLite (a_sampdb.inc)

@ATGOggy: It takes time to learn SQL. Doesn't mean you should resort to awful methods.
Reply
#4

You should not use dini but you can use y_ini. INI is the easiest way than SQL. Read my signature.
Reply
#5

It's still not ideal for what he's trying to do. Why not have a single query that would return everything he needs?
Reply
#6

To do anything in SQL, you'll have to learn SQL which is not needed if you are using INI.
Reply
#7

here is the code
Quote:

stock LoadLabels()
{
new bool:Finished;
for(new i=0; !Finished; i++)
{
new string[128];
format(string, sizeof(string), "/Label/label%d.ini", i);
if(fexist(string))
{

CreateDynamic3DTextLabel(dini_Int(string, "text"), 0xFFFFFFFF, dini_Float(string, "x"), dini_Float(string, "y"), dini_Float(string, "z"), 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);//error in this line
}
else
{
Finished=true;
}
}
}

but i got this error
Quote:

error 035: argument type mismatch (argument 1)

sry for my bad english
Reply
#8

pawn Код:
stock LoadLabels()
{
    new str[128],len,File:F;
    new text[128],Float:Pos[3],idx;
    for(new i=0; i < 100; i++)
    {
        format(str, 20, "/Label/label%d.ini", i);
        F = fopen(str, io_read);
        if(!F) break; // or continue;

        idx = 0;
        while((len = fread(F,str)))
        {
            if(len > 1)
                str[len - 2] = EOS;

            if((len = strfind(str,"=",true)) != -1)
            {
                switch(++idx)
                {
                    case 1: strcat((text[0]=EOS,text),str[len+1]);
                    case 2..4: Pos[idx-2] = floatstr(str[len+1]);
                    default:
                    {
                        CreateDynamic3DTextLabel(text, 0xFFFFFFFF, Pos[0], Pos[1], Pos[2], 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
                        break;
                    }
                }
            }
        }
        fclose(F);
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)