在非程序循环脚本中找不到标识符

Indentifier not found in non-program loop script

我试图查找 "identifier not found" 错误只是为了找到必须将函数移出主循环或应该使用前向声明的帖子。但是,我的脚本用作游戏引擎的模块,因此没有真正的主循环,并且有问题的函数由失败行上方的另一个函数调用,没有问题:

// Create a Steam ID
CSteamID Steam::createSteamID(uint32 steamID, int accountType){
    CSteamID cSteamID;
    if(accountType < 0 || accountType >= k_EAccountTypeMax){
        accountType = 1;
    }
    cSteamID.Set(steamID, EUniverse(k_EUniversePublic), EAccountType(accountType));
    return cSteamID;
}

// Set a Steam user as someone recently played with
void Steam::setPlayedWith(int steamID){
    if(SteamFriends() == NULL){
        return;
    }
    CSteamID friendID = createSteamID(steamID);
    SteamFriends()->SetPlayedWith(friendID);
}

// Get friend's Steam username
String getFriendPersonaName(int steamID){
    if(SteamFriends() == NULL || steamID == 0){
        return "";
    }
    CSteamID friendID = createSteamID(steamID);
    bool isDataLoading = SteamFriends()->RequestUserInformation(friendID, true);
    if(!isDataLoading){
        return SteamFriends()->GetFriendPersonaName(friendID);
    }
}

ID创建功能位于最顶部,这两个功能要晚得多。第一个 (setPlayedWith) 成功没问题,但第二个 (getFriendPersonaName) 失败并显示:'createSteamID':编译脚本时找不到标识符。

我有点不知所措,希望有人能给我指出正确的方向。

如果 getFriendPersonaName() 是一个成员函数,那么您忘记了以正确的方式定义它,因此它看起来像:

string Steam::getFriendPersonaName(int steamID)...

如果不是会员则无法访问。但是,如果 getFriendPersonaName() 是好友函数,您只能访问它,您应该将签名编辑为:

String getFriendPersonaName(int steamID, const steam& rhs);