Reputation: 23
I have got problem, without this:
std::sort(TargetList, TargetList+targetLoop, CompareTargetEnArray());
Everything works fine, but with this line above me, compilating does not work.
struct CompareTargetEnArray
{
bool operator() (TargetList_t & lhs, TargetList_t & rhs)
{
return lhs.Distance < rhs.Distance;
}
};
void Aimbot()
{
TargetList_t * TargetList = new TargetList_t[NumOfPlayers];
int targetLoop = 0;
for(int i = 0; i < NumOfPlayers; i ++)
{
PlayerList[i].ReadInformation(i);
if(PlayerList[i].Team == MyPlayer.Team)
continue;
if (PlayerList[i].Health < 2)
continue;
//PlayerList[i].Position[2] -= 10;
CalcAngle (MyPlayer.Position, PlayerList[i].Position, PlayerList[i].AimbotAngle);
TargetList[targetLoop] = TargetList_t(PlayerList[i].AimbotAngle, MyPlayer.Position,PlayerList[i].Position);
targetLoop++;
}
if(targetLoop > 0)
{
std::sort(TargetList, TargetList+targetLoop, CompareTargetEnArray());
if (!GetAsyncKeyState(0x2))
{
WriteProcessMemory (fProcess.__HandleProcess,(PBYTE*)(fProcess.__dwordEngine + dw_m_angRotation),
TargetList[0].AimbotAngle, 12, 0);
}
}
targetLoop = 0;
delete [] TargetList;
}
I cannot fix this... only removing this
std::sort(TargetList, TargetList+targetLoop, CompareTargetEnArray());
resolves the problem, but 'program' does not work propertly. And do not ask me why I am writing a some kind of aimbot, only for my purposes. Errors:
c:\program files (x86)\codeblocks\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_algo.h|2287|error: no match for call to '(CompareTargetEnArray) (TargetList_t&, const TargetList_t&)'
c:\program files (x86)\codeblocks\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_algo.h|2290|error: no match for call to '(CompareTargetEnArray) (const TargetList_t&, TargetList_t&)'|
Upvotes: 2
Views: 1270
Reputation: 76240
Your functor should be:
struct CompareTargetEnArray {
bool operator() (TargetList_t const& lhs, TargetList_t const& rhs) const {
// ^^^^^ ^^^^^ ^^^^^
return lhs.Distance < rhs.Distance;
}
};
Also, please use std::vector
.
Upvotes: 3