How to fix im new

Status
Not open for further replies.

Monster4k

Newbie
Newbie
Newbie
Newbie
Status
Offline
Joined
Jun 12, 2019
Messages
1
Reaction score
0
C++:
void Menu::SpectatorList()
{
    if (!g_EngineClient->IsInGame() || !g_LocalPlayer)
        return;

    std::string spectators;

    for (int i = 0; i < g_EngineClient->GetMaxClients(); i++)
    {
        C_BasePlayer* entity = C_BasePlayer::GetPlayerByIndex(i);

        if (!entity)
            continue;

        if (entity->IsAlive())
            continue;

        if (entity->IsDormant())
            continue;

        if (!entity->m_hObserverTarget())
            continue;

        C_BasePlayer* target = entity->m_hObserverTarget();

        if (!target->IsPlayer())
            continue;

        player_info_t entityinfo = entity->GetPlayerInfo();
        player_info_t targetinfo = target->GetPlayerInfo();

        spectators += std::string(entityinfo.szName) + " > " + targetinfo.szName + "\n";
    }

   

    ImGui::SetNextWindowSize(ImVec2(300, size.y + 40.f));
    if (ImGui::Begin("Spectator List", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse))
    {
        ImGui::Text(spectators.c_str());
        ImGui::End();
    }
}

based on:CSGOSimple
 

Attachments

  • Capture.PNG
    Capture.PNG
    2.4 KB · Views: 14
Last edited by a moderator:

sanikbug2k18

Newbie
Newbie
Newbie
Newbie
Status
Offline
Joined
Jun 15, 2020
Messages
9
Reaction score
2
ImGui::SetNextWindowSize(ImVec2(300, size.y + 40.f)); if (ImGui::Begin("Spectator List", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse)) { ImGui::Text(spectators.c_str()); ImGui::End(); }
i'm new too but the imgui::end should be outside not inside.
like this:

C++:
    ImGui::SetNextWindowSize(ImVec2(300, size.y + 40.f));
    if (ImGui::Begin("Spectator List", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse))
    {
        ImGui::Text(spectators.c_str());
        
    }
    ImGui::End();
 
Status
Not open for further replies.
Top