Reading with dini
#1

I made function, that reads vehicles from file (one vehicle in one file). There are 30 files with vehicles, and i am trying to read from them:
pawn Код:
new Float:cX, Float:cY, Float:cZ, Float:cA;
new cmodel;
for(new i=1; i<30; i++)
{
    new string[256];
    format(string, sizeof(string), "/Cars/%s.ini", i);
    cX = dini_Get(string, "X");
    cY = dini_Get(string, "Y");
    cZ = dini_Get(string, "Z");
    cA = dini_Get(string, "A");
    cmodel = dini_Int(string, "Model");
    CreateVehicle(cmodel, cX, cY, cZ, cA, -1, -1, RESPAWN);
}
Will this read from all files? /Cars/%s.ini - %s is carname, which is saved. And i get errors:
Код:
C:\DOCUME~1\Arnoldas\Desktop\Serveris\FILTER~1\Market.pwn(59) : error 006: must be assigned to an array
C:\DOCUME~1\Arnoldas\Desktop\Serveris\FILTER~1\Market.pwn(60) : error 006: must be assigned to an array
C:\DOCUME~1\Arnoldas\Desktop\Serveris\FILTER~1\Market.pwn(61) : error 006: must be assigned to an array
C:\DOCUME~1\Arnoldas\Desktop\Serveris\FILTER~1\Market.pwn(62) : error 006: must be assigned to an array
The lines are:
pawn Код:
cX = dini_Get(string, "X");
cY = dini_Get(string, "Y");
cZ = dini_Get(string, "Z");
cA = dini_Get(string, "A");
Reply
#2

You must use dini_Float instead of dini_Get

dini_Get retrives a string

dini_Float retrieves a float
Reply
#3

Will my code read from all files from /Cars/ folder?
Reply
#4

Quote:
Originally Posted by Scott[LT
]
Will my code read from all files from /Cars/ folder?
Quote:
Originally Posted by Scott[LT
]
pawn Код:
new Float:cX, Float:cY, Float:cZ, Float:cA;
new cmodel;
for(new i=1; i<30; i++)
{
    new string[256];
    format(string, sizeof(string), "/Cars/%s.ini", i);
..
Just for 30 cars. Use MAX_VEHICLES instead of 30.
Reply
#5

Well, when i type /savecar [name] dini creates file "%s.ini" - name. There are 30 files of saved vehicles with that command. It saves coordinates and model id. How to read from all of these files?
Reply
#6

Well what i did is i have a ini file called Main.ini that says how many cars have been saved.

And all the cars are saved numbered like

1.ini
2.ini
3.ini
4.ini
etc.
etc.


and then i get the number of cars saved from main.ini when loading them
Reply
#7

pawn Код:
while(cars < ids)
{
  if(cars == ids) print("cars loaded");
  else
  {
    new Float:cX, Float:cY, Float:cZ, Float:cA;
    new cmodel;
    new string[50];
    format(string, sizeof(string), "/Masinos/%s.ini", cars);
    if(dini_Exists(string))
    {
      cX = dini_Float(string, "X");
          cY = dini_Float(string, "Y");
      cZ = dini_Float(string, "Z");
      cA = dini_Float(string, "A");
      cmodel = dini_Int(string, "Modelis");
      CreateVehicle(cmodel, cX, cY, cZ, cA, -1, -1, RESPAWN);
      cars++;
    }
  }
}
Whats wrong with that code? I used Lavamike's example. Server doesn't read from line "if(dini_Exists(string))". Please help.
Reply
#8

Where do you define: cars
?
Reply
#9

pawn Код:
new cars = 0;
At the top of my filterscript
Reply
#10

cars is a number, not a string. So:

format(string, sizeof(string), "/Masinos/%s.ini", cars);

should be

format(string, sizeof(string), "/Masinos/%i.ini", cars);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)