>#include "stdafx.h"
>#include <Windows.h>
>#include <iostream>
using namespace std;
HANDLE pHandle;
class Player
{
public:
//Client Player
DWORD_PTR clientPlayer;
char Name[0x10];
unsigned int m_teamId;
//ClientControllableEntity
DWORD_PTR clientSoldier;
BYTE isOccluded;
//ClientSoldierReplication
DWORD_PTR clientReplication;
int state;
//LifeModule
DWORD_PTR healthcomponent;
FLOAT health;
};
class LocalPlayer : public Player
{
public:
DWORD_PTR VehicleVelocityA;
DWORD_PTR VehicleVelocityB;
DWORD_PTR VehicleVelocityC;
INT VehicleSpeed;
};
LocalPlayer lPlayer;
int readSpeed(LocalPlayer* localPlayer){
ReadProcessMemory(pHandle, (void*)(localPlayer->clientSoldier + 0x0280), &localPlayer->VehicleVelocityA, sizeof(localPlayer->VehicleVelocityA), NULL);
ReadProcessMemory(pHandle, (void*)(localPlayer->clientSoldier + 0x0284), &localPlayer->VehicleVelocityB, sizeof(localPlayer->VehicleVelocityB), NULL);
ReadProcessMemory(pHandle, (void*)(localPlayer->clientSoldier + 0x0288), &localPlayer->VehicleVelocityC, sizeof(localPlayer->VehicleVelocityC), NULL);
double VelocityAX = pow(localPlayer->VehicleVelocityA.x, 2);
double VelocityBX = pow(localPlayer->VehicleVelocityB.x, 2);
double VelocityCX = pow(localPlayer->VehicleVelocityC.x, 2);
localPlayer->VehicleSpeed = 0;
localPlayer->VehicleSpeed = sqrt(VelocityAX + VelocityBX + VelocityCX) * 3.6f;
}
有人可以帮我解决上面的代码吗?我得到表达式必须在这些行上有类错误
double VelocityAX = pow(localPlayer->VehicleVelocityA.x, 2);
double VelocityBX = pow(localPlayer->VehicleVelocityB.x, 2);
double VelocityCX = pow(localPlayer->VehicleVelocityC.x, 2);
它告诉我本地玩家必须有类型。有人可以帮助我调试这段代码,这让我烦恼了好几个小时。
答案 0 :(得分:1)
DWORD_PTR是一个指针,而不是一个结构。这就是为什么它会出错。
需要pow
或double
的{{1}}函数。
将float
和其他变量声明为VehicleVelocityA
或double
,或将结构包含float
作为x
或double
。