Load strings with file.inc or yini from file. -
DiNorscio - 25.06.2014
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'
Re: Load strings with file.inc or yini from file. -
DiNorscio - 25.06.2014
Any solutions?
Re: Load strings with file.inc or yini from file. -
Jack_Leslie - 25.06.2014
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.
Re: Load strings with file.inc or yini from file. -
DiNorscio - 26.06.2014
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(pos, string))
{
format(string, sizeof(string), "%s TIP:1\n", string);
new File:ftw=fopen(UserPath(playerid), io_append);
fwrite(ftw, "TIKET:\n");
fwrite(ftw, string);
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.
Re: Load strings with file.inc or yini from file. -
BroZeus - 26.06.2014
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);
Re: Load strings with file.inc or yini from file. -
RodriguezFais - 26.06.2014
hm.m.
Re: Load strings with file.inc or yini from file. -
DiNorscio - 26.06.2014
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?
Re: Load strings with file.inc or yini from file. -
BroZeus - 26.06.2014
after loading to send it as message use this--
pawn Код:
for(new i= 0; i <=var; i++)
{
SendClientMessage(playerid, -1, store[i]);
}
Re: Load strings with file.inc or yini from file. -
DiNorscio - 26.06.2014
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(pos, string))
{
format(string, sizeof(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
Re: Load strings with file.inc or yini from file. -
BroZeus - 26.06.2014
make sure in enum ppar1 looks something like this
pPar1[100]
and to sotre use this
format(PlayerInfo[playerid][pPar1], 100, "%s", string);