-
Автор темы
- #1
C++:
void Visuals::RenderSpectatorList() {
int specs = 0;
std::string spect = "";
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::PushStyleVar(ImGuiStyleVar_WindowTitleAlign, ImVec2(0.5f, 0.5f));
if (ImGui::Begin("Spectator List", nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar)) {
draw_list ->AddLine(ImVec2(0, 0), ImVec2(200, 2), ImColor(195, 0, 132, 255), 1.f);
spectators += "\n";
ImVec2 size = ImGui::CalcTextSize(spectators.c_str());
ImGui::SetWindowSize(ImVec2(200, 25 + size.y));
ImGui::Text(spectators.c_str());
}
ImGui::End();
ImGui::PopStyleVar();
}