Wiseacre2000 2023-01-23 15:27 采纳率: 50%
浏览 65
已结题

游戏程序报错:表达式必须是可修改的左值

C++编程:表达式必须是可修改的左值

报错:
①表达式必须是可修改的左值 "weaponType":不能给常量赋值
②表达式必须是可修改的左值 “=”:左操作数必须为左值

如图一:

img

如图二:

img

图一:

#include "aimbot.h"

#include "../core/globals.h"
#include "../core/interfaces.h"

void hacks::RunAimbot(CUserCmd* cmd) noexcept
{
    // check if we are trying to shoot
    if (!(cmd->buttons & CUserCmd::IN_ATTACK))
        return;

    if (globals::localPlayer->IsDefusing())
        return;

    CEntity* activeWeapon = globals::localPlayer->GetActiveWeapon();

    if (!activeWeapon)
        return;

    const int weaponType = activeWeapon->GetWeaponType();

    switch (weaponType)
    {
    case CEntity::WEAPONTYPE_MACHINEGUN:
    case CEntity::WEAPONTYPE_RIFLE:
    case CEntity::WEAPONTYPE_SHOTGUN:
    case CEntity::WEAPONTYPE_SNIPER:
    case CEntity::WEAPONTYPE_PISTOL:
    {
        if (!activeWeapon->GetClip())
            return;

        if (weaponType = CEntity::WEAPONTYPE_SNIPER)
        {
            if (!globals::localPlayer->IsScoped())
                return;
        }

        break;
    }

    default:
        return;
    }

图二:

CVector bestAngle{ };
    float bestFov{ 5.f };

    for (int i = 1; i <= interfaces::globals->maxClients; ++i)
    {
        CEntity* player = interfaces::entityList->GetEntityFromIndex(i);

        if (!player)
            continue;

        if (player->IsDormant() || !player->IsAlive())
            continue;

        if (player->GetTeam() = globals::localPlayer->GetTeam())
            continue;

        if (player->HasGunGameImmunity())
            continue;

        // player's bone matrix
        CMatrix3x4 bones[128];
        if (!player->SetupBones(bones, 125, 256, interfaces::globals->currentTime))
            continue;

        // our eye position
        CVector localEyePostition;
        globals::localPlayer->GetEyePosition(localEyePostition);

        // our aim punch
        CVector aimPunch{ };

        switch (weaponType)
        {
        case CEntity::WEAPONTYPE_RIFLE:
        case CEntity::WEAPONTYPE_SUBMACHINEGUN:
        case CEntity::WEAPONTYPE_MACHINEGUN:
            globals::localPlayer->GetAimPunch(aimPunch);
        }

  • 写回答

3条回答 默认 最新

  • 阳光宅男xxb 2023-01-23 15:38
    关注

    判断相等是用两个等于号==不是一个,一个表示赋值

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 1月31日
  • 已采纳回答 1月23日
  • 创建了问题 1月23日

悬赏问题

  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题