So I have two arrays which hold players x, y and z co-ordinates, however each time I call them they change their values the first time they are printed to the console they display the correct result however subsequent prints to the screen yield very small numbers,
HisPosition = GetPlayerPosition(aPlayer);
std::cout << "TheirPos=" << std::dec << HisPosition[0] << std::endl;
std::cout << "TheirPos1=" << std::dec << HisPosition[0] << std::endl;
if(!isnan(HisPosition[0])){
std::cout << "TheirPos2=" << std::dec << HisPosition[0] << std::endl;
Example console output:
TheirPos=440
TheirPos1=1.7118e-037
TheirPos2=1.7118e-037
They are defined like so:
float* HisPosition;
And GetPlayerPosition:
float* GetPlayerPosition(DWORD dwBase)
{
float result [3];
DWORD aXPos = dwBase + 0x134;
DWORD aYPos = dwBase + 0x138;
DWORD aZPos = dwBase + 0x13C;
result[0] = Read<float>(aXPos);
result[1] = Read<float>(aYPos);
result[2] = Read<float>(aZPos);
return result;
}
aPlayer stands for the address in memory of the player I am trying to fetch the offsets are correct as on the first console print the position is correct.
I'm new to using arrays in C++ and would appreciate any guidance.