10.04.2013, 11:21
Hey,
I Need a function wich will load all of my objects from a ini file.
I saw this function -
But it dont work for me.
I've printed the poses from that function and it loads only : "0.00000" for everthing(Object Model,FloatX and so..).
I Need a function wich will load all of my objects from a ini file.
I saw this function -
Код:
stock LoadObjectsFromFile(const filename[])
{
new Objects_loaded;
if(!fexist(filename))
return printf("[Objects] Couldn't load objects from %s [Reason : File doesn't exist]", filename);
new File:Handler = fopen(filename, io_read);
if(!Handler) return printf("[Objects] Couldn't load objects from %s [Reason : I/O Error]", filename);
new Line[256], Index = -1, Model, Float:PosX, Float:PosY, Float:PosZ, Float:RotX, Float:RotY, Float:RotZ,Float:DrawDistance;
Objects_loaded = 0;
while(fread(Handler, Line))
{
Index++;
new EOL = strfind(Line, ";", false);
if(EOL != -1) strdel(Line, EOL - 1, sizeof Line - 1);
else
{
printf("[Objects] Error reading @LineIndex %i from %s (EOL not found)", Index, filename);
continue;
}
if(!sscanf(Line[13], "p<,>iffffffF(100)", Model, PosX, PosY, PosZ, RotX, RotY, RotZ, DrawDistance))
{
CreateObject(Model, PosX, PosY, PosZ, RotX, RotY, RotZ, DrawDistance);
Objects_loaded++;
}
else printf("[Objects] Error reading @LineIndex %i from %s (Invalid format)", Index, filename);
}
fclose(Handler);
printf("[Objects] Loaded %d objects from: %s", Objects_loaded, filename);
return true;
}
I've printed the poses from that function and it loads only : "0.00000" for everthing(Object Model,FloatX and so..).

