LoadObjectsFromFile Needed ! Get IN ! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: LoadObjectsFromFile Needed ! Get IN ! (
/showthread.php?tid=429587)
LoadObjectsFromFile Needed ! Get IN ! -
sKgaL - 10.04.2013
Hey,
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;
}
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..).
Re: LoadObjectsFromFile Needed ! Get IN ! -
Pottus - 10.04.2013
Heres is your problem right here "Line[13]" you using sscanf on only one array value in your string if you only want from that part of your string on wards you'll need to use strmid like this I believe.
strmid(line,line,13,256,256);
Re: LoadObjectsFromFile Needed ! Get IN ! -
sKgaL - 11.04.2013
I didnt undrstand...
Can you fix that function for me ?
Thank you very much for your comment
Re: LoadObjectsFromFile Needed ! Get IN ! -
Pottus - 11.04.2013
Can you post a few lines of the file you are trying to read thanks.