c++ - 为什么我在“找不到‘X’标识符’”时出现错误
问题描述
所以我试图用 c++ 为 CS:GO 编写一个基本的 triggerbot 来练习我的游戏黑客,一切都很顺利,在我尝试编译之前没有错误。
我的代码
触发机器人.cc
#include "ProcMem.h"
#include "csgo.hpp"
#include <ctime>
#include <chrono>
#include <iostream>
#include <Windows.h>
#include "triggerbot.h"
using namespace hazedumper;
using namespace signatures;
using namespace netvars;
ProcMem Memory;
DWORD ClientDLL;
DWORD localPlayer;
const DWORD teamOffset = 0xF4;
const DWORD hpOffset = 0x100;
const DWORD ELD = 0x10;
int mainProcess() {
char process[9] = "csgo.exe";
char module[20] = "client_panorama.dll";
Memory.Process(process);
ClientDLL = Memory.Module(module);
localPlayer = Memory.Read<DWORD>(ClientDLL + dwLocalPlayer);
while (true)
{
Shoot();
Sleep(1);
}
}
void Shoot()
{
DWORD activeWeapon = Memory.Read<DWORD>(localPlayer + m_hActiveWeapon);
DWORD entID = activeWeapon & 0xFFF;
DWORD weapID = Memory.Read<DWORD>(ClientDLL + dwEntityList + (entID - 1) * 0x10);
int myWeapID = Memory.Read<int>(weapID + m_iItemDefinitionIndex);
bool scopedIn = Memory.Read<bool>(localPlayer + m_bIsScoped);
int myTeam = Memory.Read<int>(localPlayer + teamOffset);
int crossEnt = Memory.Read<int>(localPlayer + m_iCrosshairId);
DWORD Entity = Memory.Read<DWORD>(ClientDLL + dwEntityList + (crossEnt - 1) * 0x10);
int enemyHP = Memory.Read<int>(Entity + hpOffset);
int enemyTeam = Memory.Read<int>(Entity + teamOffset);
if (GetKeyState(VK_LMENU) && 0x8000 && enemyTeam != myTeam && enemyHP > 0);
bool weapon = (myWeapID == 9) || (myWeapID == 40) || (myWeapID == 38) || (myWeapID == 11);
if ((weapon && scopedIn) || !weapon) {
Sleep(1);
Memory.Write<int>(ClientDLL + dwForceAttack, 5);
Sleep(18);
Memory.Write<int>(ClientDLL + dwForceAttack, 4);
Sleep(350);
}
}
错误
Error C3861 'Shoot': identifier not found
为什么没有找到标识符“Shoot”,即使它在下面声明为
void Shoot()
有人请告诉我我做错了什么。
解决方案
移动Shoot
上面的函数mainProcess
:
void Shoot() {
//...
}
int mainProcess() {
//...
}
Shoot
或在上面转发声明mainProcess
:
void Shoot(); // forward declaration
int mainProcess() {
//...
}
void Shoot() {
//...
}
还要确保将ProcMem.cpp
其作为源文件添加到您的项目中。
推荐阅读
- python - 在 USB 上运行 Python
- excel - 有没有办法让我的公式引用单个单元格值,以便我可以使用一个单元格更改多个公式?
- c# - 获取刷过的项目并设置其 BindingContext 空白 ListView
- c# - 包含枚举值的 InputSelect 占位符
- python - 如何通过 IIS 向 Flask Oracle 连接传递 kerberos 身份验证?
- outlook - 适用于仅命令加载项的 Office 365 清单
- javascript - 如何遍历 Typescript 中的地图:for...in?为了……的?为每个?
- powershell - 使用 Powershell 部署 SSIS - 缺少 DMF
- datetime - 如何判断给定的 NaiveDateTime(加上像“US/Mountain”这样的时区)是否在 Elixir 的过去?
- mongodb - 如何使用驱动程序在 MongoDB 中进行文档版本控制