07.12.2010, 18:43
i want load pickups from file in command, in taht way, in file:
"pickup %d %d %f %f %f" or "CreatePickup(...."
"pickup %d %d %f %f %f" or "CreatePickup(...."
forward LoadPickUps();
enum puInfo
{
puModel,
puType,
Float:puCoordX,
Float:puCoordY,
Float:puCoordZ,
puVirtualW,
};
new PickUpInfo[MAX_PLAYERS][puInfo];
public LoadPickUps()
{
new Coords[30][128];
new string[256];
new File: file = fopen("pickups.txt", io_read);
if(file)
{
new idx;
while (idx < sizeof(PickUpInfo))
{
fread(file, string);
split(string, Coords, ',');
PickUpInfo[idx][puModel] = floatstr(Coords[0]);
PickUpInfo[idx][puType] = floatstr(Coords[1]);
PickUpInfo[idx][puCoordX] = floatstr(Coords[2]);
PickUpInfo[idx][puCoordY] = floatstr(Coords[3]);
PickUpInfo[idx][puCoordZ] = floatstr(Coords[4]);
PickUpInfo[idx][puVirtualW] = floatstr(Coords[5]);
idx++;
}
fclose(file);
}
return 1;
}
LoadPickUps();
for(new p = 0; p < sizeof(PickUpInfo); p++)
{
CreatePickup(PickUpInfo[p][puModel], PickUpInfo[p][puType], PickUpInfo[p][puCoordX], HouseInfo[p][puCoordY], HouseInfo[p][puCoordZ], PickUpInfo[p][puVirtualW]);
}