Reading with dini -
arnutisz - 11.07.2009
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");
Re: Reading with dini -
lavamike - 11.07.2009
You must use dini_Float instead of dini_Get
dini_Get retrives a string
dini_Float retrieves a float
Re: Reading with dini -
arnutisz - 11.07.2009
Will my code read from all files from /Cars/ folder?
Re: Reading with dini -
Correlli - 11.07.2009
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.
Re: Reading with dini -
arnutisz - 11.07.2009
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?
Re: Reading with dini -
lavamike - 11.07.2009
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
Re: Reading with dini -
arnutisz - 12.07.2009
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.
Re: Reading with dini -
lavamike - 12.07.2009
Where do you define: cars
?
Re: Reading with dini -
arnutisz - 12.07.2009
At the top of my filterscript
Re: Reading with dini -
lavamike - 12.07.2009
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);