bakkesmodorg / BakkesModSDK

The current BakkesModSDK (Unofficial SDK for Rocket League)
http://bakkesmod.com
223 stars 49 forks source link

Getting members of online game doesn't work #9

Closed itsZeebo closed 3 years ago

itsZeebo commented 4 years ago

Description

When trying to get members of a team using the GetMembers() function of TeamWrapper in an online game, there are 0 members in both teams.

Example

// an event handler for when a goal is being scored hooked to the 'Function TAGame.Team_TA.EventScoreUpdated' event
void CoolPlugin::goalScored()
{
    ServerWrapper server = gameWrapper->GetOnlineGame();
    ArrayWrapper<TeamWrapper> teams = server.GetTeams();

    for (int idxTeam = 0; idxTeam < teams.Count(); idxTeam++) {
        TeamWrapper team = teams.Get(idxTeam);

        if (!team.IsNull()) {
            ArrayWrapper<PriWrapper> teamMembers = team.GetMembers();

            for (int idxTeamMember = 0; idxTeamMember < teamMembers.Count(); idxTeamMember++) {
                PriWrapper player = teamMembers.Get(idxTeamMember);
            }
        }
    }
}

Expected Result

Loop through the team players and be able to access their data.

Actual Result

We are able to get 2 teams from the server.GetTeams() function, but teamMembers.Count() returns 0 and there aren't any members to loop through. Also teamMembers.Get(0) returns null.

CinderBlocc commented 3 years ago

If that issue only shows up in online play, and not in offline play, then it's likely the variable that stores those members doesn't get replicated. Your best bet would be to use server.GetPRIs() and loop through those. You can use PriWrapper::GetTeamNum() to get which team they're on. 0 is blue, 1 is orange.