07.12.2014, 21:21
Try this:
It's much shorter and better looking as well.
You'll need to have sscanf plugin:
https://sampforum.blast.hk/showthread.php?tid=120356
pawn Код:
stock LoadObjectsFromFile(const filename[])
{
new File:file = fopen(filename, io_read);
if (!file) return 0;
TotalObjects = 0;
new line[100], modelid, Float:Pos[6];
while (fread(file, line))
{
// Use "," as delimiter and read one integer and 6 floats, and store the values in the following variables
sscanf(line, "p<,>iffffff", modelid, Pos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5]);
ActivityObject[TotalObjects] = CreateDynamicObject(modelid, Pos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5], ActivityInfo[ActivityNumber][a_VirtualWorld], ActivityInfo[ActivityNumber][a_Interior]);
TotalObjects++;
}
fclose(file);
return printf("Objects Loaded: %d", TotalObjects);
}
You'll need to have sscanf plugin:
https://sampforum.blast.hk/showthread.php?tid=120356