Load strings with file.inc or yini from file.
#1

Hello there,

I have on my server basic register/login system and it's works, YINI do that job very good.
Now I started to create something from my idea, and now i create everything, to save in user ini file 3-5 lines and it saves okay but now I want to load that strings but only that 3-5 no whole file and to put it in SendClientMessage (I will after do something with that).

Short story:

I dont know how to load EXACTLY LINES UNDER TAG (which I also create).


Again, this is how my user ini's looks:
Quote:

[data]
Password = 19726487
Cash = 0
Admin = 0
Kills = 0
Deaths = 0
[fromhere]
bla
bla
bla
bla
bla
[tohere]

and I want to load JUST THAT LINES BEETWEEN TAGS 'fromhere' and 'tohere'
Reply
#2

Any solutions?
Reply
#3

Just load the data into the variables.. and use them?

pawn Код:
PlayerInfo[playerid][bla] = // yini code to load bla
There you have bla, bla. Bla? I don't bla understand why you just don't bla load the data and bla store them into the bla variables, bla bla.
Reply
#4

How to make that? Example please, I want when player do my command to save that 'bla' string in his ini file.

Like this:

PHP код:
                                 new string[256];
                    new 
File:pos=fopen("Parovi.txt"io_readwrite);
                    while(
fread(posstring))
                    {
                    
format(stringsizeof(string), "%s TIP:1\n"string);
                    new 
File:ftw=fopen(UserPath(playerid), io_append);
                    
fwrite(ftw"TIKET:\n");
                    
fwrite(ftwstring);
                    
fclose(ftw);
                    
fclose(pos);
                    } 
and you see that I saved that string in his UserPath (ini.file) but I dont know how to load it.
Can you make me that PlayerInfo[playerid][bla] = // yini code to load bla , to save like that and example how to load it after saving.

Regards.
Reply
#5

well it would work like this
but make sure in ur "bla bla bla" there is no "=" sign
pawn Код:
//on top
#define MAX_STRING_FROM_FILE 50
new store[MAX_STRING_FROM_FILE][];


//the reading part
new var=0,line[100];
new File:file=fopen("FILENAME",io_read);

while(fread(file,line))
{
if(strfind(line,"=") != -1)continue;
format(store[var],100,"%s",line);
var++;
}
fclose(file);
Reply
#6

hm.m.
Reply
#7

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
well it would work like this
but make sure in ur "bla bla bla" there is no "=" sign
pawn Код:
//on top
#define MAX_STRING_FROM_FILE 50
new store[MAX_STRING_FROM_FILE][];


//the reading part
new var=0,line[100];
new File:file=fopen("FILENAME",io_read);

while(fread(file,line))
{
if(strfind(line,"=") != -1)continue;
format(store[var],100,"%s",line);
var++;
}
fclose(file);
And how after, load that string in SendClientMessage for example?
Reply
#8

after loading to send it as message use this--
pawn Код:
for(new i= 0; i <=var; i++)
{
SendClientMessage(playerid, -1, store[i]);
}
Reply
#9

I dont to complicate like this, I want to know how to make using PlayerInfo for that my strings, if anyone know any solution,idea please reply.

Now I'm on this:

I have created:
PHP код:
public LoadUser_data(playerid,name[],value[])
{
    
INI_Int("Password",PlayerInfo[playerid][pPass]);
    
INI_Int("Cash",PlayerInfo[playerid][pCash]);
    
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    
INI_Int("Kills",PlayerInfo[playerid][pKills]);
    
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    
INI_Int("1.PAR",PlayerInfo[playerid][pPar1]);
    return 
1;

but dont know how to save from this
PHP код:
new string[256];
                    new 
File:pos=fopen("Parovi.txt"io_readwrite);
                    while(
fread(posstring))
                    {
                    
format(stringsizeof(string), "%s TIP:1\n"string);
                    
PlayerInfo[playerid][pPar1] = string);
                    
/*new File:ftw=fopen(UserPath(playerid), io_append);
                    fwrite(ftw, "TIKET:\n");
                    fwrite(ftw, string);
                    fclose(ftw);
                    fclose(pos);*/
                    
new INI:File INI_Open(UserPath(playerid));
                    
INI_WriteInt(File,"1.PAR",PlayerInfo[playerid][pPar1]);
                    
INI_Close(File); 
it says array must be indexed on line PlayerInfo[playerid][pPar1] = string);
how to save that string in that pPar1
Reply
#10

make sure in enum ppar1 looks something like this
pPar1[100]
and to sotre use this
format(PlayerInfo[playerid][pPar1], 100, "%s", string);
Reply


Forum Jump:


Users browsing this thread: