Once the numbers are saved to the file they're no longer floats, they are just a bunch of characters. So when you read from the file all you're getting is the string representation of those numbers and not the numbers themselves. You're storing these characters in a string called "lineBuffer", which is just an array of characters. So lineBuffer[0] would give you the first character and not the first number. Same with lineBuffer[1] and lineBuffer[2].
What you need to do to is first of all separate these 3 numbers, which can be easily done with
ExplodeString, and then converting them to a float so they can be used by using
StringToFloat with each number seperated.
Another alternative is to not convert the floats to string to begin with. If the file doesn't need to be readable, you can just store the raw bytes.
That implementation would look something like this:
PHP Code:
public Action SpawnDesiredNPC(Handle timer, int entity)
{
char targetname[128];
GetEntPropString(entity, Prop_Data, "m_iName", targetname, sizeof(targetname));
if(StrEqual(targetname,"zombie1"))
{
float npcPosition[3];
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", npcPosition);
float npcAngle[3];
GetEntPropVector(entity, Prop_Send, "m_angRotation", npcAngle);
char path[PLATFORM_MAX_PATH];
CreateDirectory("addons/sourcemod/data/phoneburnia", 3);
BuildPath(Path_SM, path, sizeof(path), "data/phoneburnia/zombie1.txt");
File fileHandle = OpenFile(path, "w");
fileHandle.Write(npcPosition, sizeof(npcPosition), 4); // 3 items in the array, each is 4 bytes
fileHandle.Write(npcAngle, sizeof(npcAngle), 4);
fileHandle.Close();
CreateTimer(5.0, ZombieSpawner1, entity);
}
}
public Action ZombieSpawner1(Handle timer, int entity)
{
char path[PLATFORM_MAX_PATH];
BuildPath(Path_SM, path, sizeof(path), "data/phoneburnia/zombie1.txt");
float npcPosition[3];
float npcAngle[3];
File fileHandle = OpenFile(path, "r");
fileHandle.Read(npcPosition, sizeof(npcPosition), 4) // read 3 items, 4 bytes each, and store in npcPosition
PrintToServer("Pos: %f %f %f", npcPosition[0], npcPosition[1], npcPosition[2]);
fileHandle.Read(npcAngle, sizeof(npcAngle), 4) // read 3 items, 4 bytes each, and store in npcAngle
PrintToServer("Ang: %f %f %f", npcAngle[0], npcAngle[1], npcAngle[2]);
fileHandle.Close();
}