-
Автор темы
- #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";
}
if (ImGui::Begin("Spectator List", nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar)) {
ImVec2 size = ImGui::CalcTextSize(spectators.c_str());
ImGui::SetWindowSize(ImVec2(200, 35 + size.y));
auto pos = ImGui::GetWindowPos();
ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(pos.x, pos.y + 22), ImVec2(pos.x + 200, pos.y + 25), ImColor(100, 100, 255, 255), 0, 15);
ImGui::Text(spectators.c_str());
}
ImGui::End();
}
типа так