#1

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
Reply
#2

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
Reply
#3

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.
Reply
#4

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.
Reply
#5

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?
Reply
#6

why not just keep using dini/djson? its way easier
Reply
#7

Use a normal variable then
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)