-
Автор темы
- #1
C++:
void misc::spectators_list()
{
if (!g_cfg.misc.spectators_list)
return;
//if (!g_ctx.local()->is_alive())
//return;
std::vector <std::string> spectators;
for (int i = 1; i < m_globals()->m_maxclients; i++)
{
auto e = static_cast<player_t*>(m_entitylist()->GetClientEntity(i));
if (!e)
continue;
if (e->is_alive())
continue;
if (e->IsDormant())
continue;
if (e->m_hObserverTarget().Get() != g_ctx.local())
continue;
player_info_t player_info;
m_engine()->GetPlayerInfo(i, &player_info);
spectators.push_back(player_info.szName);
}
static int spec_x;
static int spec_y;
static int _drag_x = 300;
static int _drag_y = 300;
static bool _dragging = false;
bool _click = false;
if (GetAsyncKeyState(VK_LBUTTON))
_click = true;
Vector2D _mouse_pos = m_surface()->GetMousePosition();
if (_dragging && !_click)
_dragging = false;
if (_dragging && _click)
{
g_cfg.misc.spectatorlist_pos_x = _mouse_pos.x - _drag_x;
g_cfg.misc.spectatorlist_pos_y = _mouse_pos.y - _drag_y;
spec_x = g_cfg.misc.spectatorlist_pos_x;
spec_y = g_cfg.misc.spectatorlist_pos_y;
}
int spec_width = 100;
int spec_width3 = 150;
int spec_width2 = 30;
int spec_height = 22.5;
if ((m_surface()->MouseInRegion(g_cfg.misc.spectatorlist_pos_x, g_cfg.misc.spectatorlist_pos_y, spec_width, spec_height)))
{
_dragging = true;
_drag_x = _mouse_pos.x - g_cfg.misc.spectatorlist_pos_x;
_drag_y = _mouse_pos.y - g_cfg.misc.spectatorlist_pos_y;
}
int h = 0;
int h2 = 0;
for (auto& keybind : spectators)
{
h2 += 12;
}
int a;
int h4;
if (h2 < 1)
{
a = 0;
h4 = 0;
}
else
{
a = 245;
h4 = 15;
}
render::get().rect_filled(g_cfg.misc.spectatorlist_pos_x, g_cfg.misc.spectatorlist_pos_y, spec_width3, spec_height, Color(25, 25, 45, 230));
auto text_size = render::get().text_width(fonts[NAME], " Spectators");
auto text_size2 = render::get().text_width(fonts[BINDS], "b");
render::get().text(fonts[NAME], g_cfg.misc.spectatorlist_pos_x + (spec_width) / 2, g_cfg.misc.spectatorlist_pos_y + 12, Color(255, 255, 255), HFONT_CENTERED_Y, " Spectators");
render::get().text(fonts[BINDS], g_cfg.misc.spectatorlist_pos_x + (spec_width2) / 2, g_cfg.misc.spectatorlist_pos_y + 12, Color(20, 100, 200), HFONT_CENTERED_Y, "b");
render::get().rect_filled(g_cfg.misc.spectatorlist_pos_x, g_cfg.misc.spectatorlist_pos_y + 20, 150, 2, Color(25, 25, 25, 100));
for (auto i = 0; i < spectators.size(); i++)
{
int width, heigth;
m_engine()->GetScreenSize(width, heigth);
auto x = render::get().text_width(fonts[NAME], spectators.at(i).c_str()) + 6; //-V106
auto y = i * 16;
render::get().text(fonts[NAME], g_cfg.misc.spectatorlist_pos_x + 10, g_cfg.misc.spectatorlist_pos_y + 24 +h, Color::White, HFONT_CENTERED_NONE, spectators.at(i).c_str()); //-V106
render::get().text(fonts[NAME], g_cfg.misc.spectatorlist_pos_x + 85, g_cfg.misc.spectatorlist_pos_y + 24 +h, Color::White, HFONT_CENTERED_NONE, "Specting"); //-V106
h += 12;
}
}
fonts[BINDS] = create_font(crypt_str("untitled-font-1"), 18, FW_LIGHT, FONTFLAG_DROPSHADOW);
Пожалуйста, авторизуйтесь для просмотра ссылки.