首页 > 解决方案 > 为什么我在“找不到‘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()

有人请告诉我我做错了什么。

标签: c++visual-c++

解决方案


移动Shoot上面的函数mainProcess

void Shoot() {
//...
}

int mainProcess() {
//...
}

Shoot或在上面转发声明mainProcess

void Shoot(); // forward declaration

int mainProcess() {
//...
}

void Shoot() {
//...
}

还要确保将ProcMem.cpp其作为源文件添加到您的项目中。


推荐阅读