y_ini -
pasha97 - 16.03.2013
Hello, I can not understand 1 thing in y_ini. I want to make my server loading data about blocks using it, but i dont release how to do it.
The file with the data looks like:
Код:
1=534.0 83.0 6.0 3
2=434.0 94.0 4.0 3
4=174.0 36.0 1.0 2
5=835.0 25.0 7.0 2
... And etc.
Where the number before the '=' is the block ID, the first number after '=' is X coordinate, second - Y, the third is Z coordinate, and the last number is the model id of block
Using dini, getting data from it looks like:
pawn Код:
new id[100],ft[256];
for(new i=0;i<MAX_BLOCKS;i++)
{
format(id,sizeof(id),"%d",i);
if(dini_Isset(MAPFILE,id))
{
ft=dini_Get(MAPFILE,id);
//other code here
}
}
Is it possible to do the same with y_ini? Because I haven't found out how to do this
Re: y_ini -
park4bmx - 16.03.2013
I'm not at home so cant show u an example(on phone) but the way to loaded and keep them that way is to save and load them as a string, that way you can split the empty spaces
" " and into an arrey and just creat them.
I will show an example when I can(50min maybe) I someone doesn't before me ofc
Re: y_ini -
pasha97 - 16.03.2013
Quote:
Originally Posted by park4bmx
I'm not at home so cant show u an example(on phone) but the way to loaded and keep them that way is to save and load them as a string, that way you can split the empty spaces " " and into an arrey and just creat them.
I will show an example when I can(50min maybe) I someone doesn't before me ofc
|
Ok, I will wait.
Re: y_ini -
park4bmx - 16.03.2013
pawn Код:
//VARIABLES
new PString[256][MAX_BLOCKS];
//LOADING
new idStr[3],Output[80];//Output will be updated for each id!
for(new ids=0; ids <MAX_BLOCKS; ids++)
{
format(idStr,sizeof idStr,ids);
INI_ParseFile(idStr, "Blocks", false, true,ids,true,false);
GetPVarString(ID, idStr, Output, sizeof Output);
}
//CALLBACKS
forward Blocks(IDs, name[], value[]);
public Blocks(IDs, name[], value[])
{
new idStr[3];format(idStr,sizeof idStr,IDs);
if(!strcmp(name,idStr)) format(PString[IDs], sizeof PString ,value);//apply the loaded pos into a string(because the spaces are invalid formats!)
}
that will load it but i cant be asked to split the " ", use sscanf if u want.
Re: y_ini -
pasha97 - 17.03.2013
Quote:
Originally Posted by park4bmx
pawn Код:
//VARIABLES new PString[256][MAX_BLOCKS];
//LOADING new idStr[3],Output[80];//Output will be updated for each id! for(new ids=0; ids <MAX_BLOCKS; ids++) { format(idStr,sizeof idStr,ids); INI_ParseFile(idStr, "Blocks", false, true,ids,true,false); GetPVarString(ID, idStr, Output, sizeof Output); } //CALLBACKS forward Blocks(IDs, name[], value[]); public Blocks(IDs, name[], value[]) { new idStr[3];format(idStr,sizeof idStr,IDs); if(!strcmp(name,idStr)) format(PString[IDs], sizeof PString ,value);//apply the loaded pos into a string(because the spaces are invalid formats!) }
that will load it but i cant be asked to split the " ", use sscanf if u want.
|
Its' quite weired. Firstly, why there is pvarstring when the blocks load on game mode init?
Re: y_ini -
mastermax7777 - 17.03.2013
why not just keep using dini/djson? its way easier
Re: y_ini -
park4bmx - 17.03.2013
Use a normal variable then