Исходник Metamod dynamic keybinds & watermark

Статус
В этой теме нельзя размещать новые ответы.
ставлю 11 ппхудов из 9.93 скитов
 
1598559759755.png
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Решил я сделать ватермарку и кейбинды, которые легко адаптируются под любые шрифты/разрешения экрана,
которые также легко спастить.
Так же в ватермарке будет написано [debug] после названия чита, если вы компилируете в дебаге
За основу решил взять стиль метамода, ибо красиво и минималистично
В коде много комментариев, так что можно взять под основу для своей ватермарки.
Так же можно довольно поменять паддинги, все константы находятся наверху.
Все необходимые инклюды тоже написал.

Скриншоты:
BrRLTpY.png

KHOV5TV.png


Код:
C++:
Expand Collapse Copy
/*
Inclused u need:
#include <ctime> // std::time, std::put_time, std::localtime
#include <sstream> // std::ostringstream
// client_state interface for net_channel
// globals interface
*/

/*
Font setup:
create_font(font: verdana_12, windows_font_name: "Verdana", tall: 12, weight: 100, blur: 0, flags: ANTIALIAS | SHADOW, [[maybe_unused]]range_min: 0, [[maybe_unused]]range_max: 0);
*/
C++:
Expand Collapse Copy
void hud::watermark() {
    // Constants for padding, etc...
    const auto margin = 10; // Padding between screen edges and watermark
    const auto padding = 4; // Padding between watermark elements

    // Constants for colors
    const auto col_background = color(0, 0, 0, 240); // Watermark background color
    const auto col_accent = color(90, 120, 240); // Watermark line accent color
    const auto col_text = color(255, 255, 255); // Watermark text color

    // Setup time
    auto t = std::time(nullptr);
    std::ostringstream time;
    // Format: 12:59:09
    time << std::put_time(std::localtime(&t), "%H:%M:%S");

    // Cheat variables
    std::string logo = "octane";
#ifdef _DEBUG
    logo.append(" [debug]"); // :)
#endif
    const std::string user = "dungeon master";

    // Game variables
    // Mine i:: namespace == interfaces:: namespace o_0
    auto net_channel = i::client_state->m_net_channel; // Receiving ping may differ from cheat base
    auto delay = (int)(net_channel ? net_channel->get_latency(FLOW_INCOMING) : 0);
    auto tick_rate = (int)(1.f / i::globals->m_tick_interval); // m_interval_per_tick

    // Setup main watermark text
    auto text = logo + " | " + user + " | delay: " + std::to_string(delay) + "ms | " + std::to_string(tick_rate) + "tick | " + time.str().data();
    // If you has tinyformat lib you can use code below
    //auto text = tfm::format("%s | %s | delay: %ims | %itick | %s", logo, user, delay, tick_rate, time.str().data());

    // How to get screen_size o_0:
    // int w, h;
    // interfaces::surface->get_screen_size(w, h);

    //  pos
    //   v
    // [ octane | sove | delay: 0ms | 64tick | 12:59:09 ]
    // ^-^ padding                                      ^--^ margin
    //   ^--------------------------------------------^ size
    //
    // Calculating text size and position
    auto text_size = render::measure_text(font::verdana_12, text);
    // float text_size_x, text_size_y; render::get_text_size(font::verdana_12, text, text_size_x, text_size_y);
    auto text_pos = vec2(render::m_screen_size.x - margin - padding - text_size.x, // Right align + margin + padding + text_size
                                margin + padding); // Top align
    //vec2_t = (float, float)

    //pos
    // v
    // [ octane | sove | delay: 0ms | 64tick | 12:59:09 ]
    // ^-^ padding                                      ^--^ margin
    // ^------------------------------------------------^ size
    //
    // Calculating watermark background size and position
    auto bg_size = vec2(padding + text_size.x + padding, // Width
                              padding + text_size.y + padding); // Height
    auto bg_pos = vec2(render::m_screen_size.x - margin - padding - text_size.x - padding, // Right align + margin
                             margin); // Top align

    // Run on hooks::panel::paint_traverse
    // Surface rendering
    render::rect(bg_pos.x, bg_pos.y, bg_size.x, bg_size.y, col_background); // Background
    render::rect(bg_pos.x, bg_pos.y, bg_size.x, 2, col_accent); // Accent line
    render::text(text_pos.x, text_pos.y, font::verdana_12, text, col_text); // Text
}
C++:
Expand Collapse Copy
void hud::keybinds() {
    // Constants for pos, padding, etc...
    const auto pos = vec2(10, 500);
    const auto padding = 4; // Padding between keybind elements

    // Constants for colors
    const auto col_background = color(0, 0, 0, 240); // Watermark background color
    const auto col_accent = color(90, 120, 240); // Watermark line accent color
    const auto col_text = color(255, 255, 255); // Watermark text color

    // Element name
    const std::string name = "keybinds";
    const auto name_size = render::measure_text(font::verdana_12, name);
    // float name_size_x, name_size_y; render::get_text_size(font::verdana_12, name, name_size_x, name_size_y);

    //pos
    // v
    // [      keybinds      ]
    // ill have two number 9s
    // a number 9 large
    //
    // ^-^ padding
    // ^--------------^ size

    // List of keybinds
    std::vector<std::string> keybinds;

    if (true) // Here your config bool
        keybinds.push_back("ill have two number 9s");

    if (true) // Here your config bool
        keybinds.push_back("a number 9 large");

    if (true) // Here your config bool
        keybinds.push_back("a number 6 with extra dip");

    if (true) // Here your config bool
        keybinds.push_back("a number 7");

    if (true) // Here your config bool
        keybinds.push_back("two number 45s");

    if (true) // Here your config bool
        keybinds.push_back("one with cheese");

    if (true) // Here your config bool
        keybinds.push_back("and a large soda");

    // Adjust width for biggest entry
    auto biggest_text_width = name_size.x;
    // auto biggest_text_width = name_size_width;
    auto keybind_position_y = padding + name_size.y + padding + padding;

    // Run on hooks::panel::paint_traverse
    // Surface rendering
    for (std::string keybind : keybinds) {
        // Get current keybind text size
        const auto keybind_size = render::measure_text(font::verdana_12, keybind);
        // float keybind_size_x, keybind_size_y; render::get_text_size(font::verdana_12, name, keybind_size_x, keybind_size_y);

        // Check if bigger one
        biggest_text_width = std::fmaxf(biggest_text_width, keybind_size.x);

        // Render keybind name
        render::text(pos.x + padding, pos.y + keybind_position_y, font::verdana_12, keybind, col_text);

        // Calculating position for our next keybind
        keybind_position_y += keybind_size.y + padding;
    }

    auto bg_size = vec2(padding + biggest_text_width + padding,
                              padding + name_size.y + padding);

    render::rect(pos.x, pos.y, bg_size.x, bg_size.y, col_background); // Background
    render::rect(pos.x, pos.y, bg_size.x, 2, col_accent); // Accent line
    render::text(pos.x + (bg_size.x * 0.5f) - (name_size.x * 0.5f), pos.y + padding, font::verdana_12, name, col_text); // Element name
    // If your rendering class has ALIGN_CENTER flag, you can use this flag instead of - (name_size.x * 0.5f)
}

Возможные наименования структур в вашей пасте ?
color - col_t - color_t - Color
vec2 - vec2_t - vector2d - Vector2d
гейбинды пушечные, особенно на скрине
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
1598628861556.png

почему ошибки?
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
классно но я жду спектатор лист
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
C++:
Expand Collapse Copy
void hud::spectators() {
    if (g_cl.m_local
          || !g_cl.m_local->is_alive())
    return;

    // Constants for pos, padding, etc...
    const auto pos = vec2(10, 500);
    const auto padding = 4; // Padding between keybind elements

    // Constants for colors
    const auto col_background = color(0, 0, 0, 240); // Watermark background color
    const auto col_accent = color::get_accent(); // Watermark line accent color
    const auto col_text = color(255, 255, 255); // Watermark text color

    // Element name
    const std::string name = xor("spectators");
    const auto name_size = render::measure_text(font::verdana_12, name);

    //pos
    // v
    // [      spectators      ]
    // ill have two number 9s
    // a number 9 large
    //
    // ^-^ padding
    // ^--------------^ size

    // Spectators
    std::vector<std::string> spectators;

    for (auto i = 0u; i < i::globals->m_max_players; i++) {
        const auto entity = i::entity_list->get_client_entity(i);
        // Entity isn't valid
        if (!entity)
            continue;

        // Cast to player class
        const auto player = (c_cs_player*)entity;

        if (player->is_alive()
             || player->get_spectating_target() != g_cl.m_local
             || player == g_cl.m_local)
            continue;

        auto info = i::engine->get_player_info(i);

        if (info.m_is_hltv)
            continue;

        spectators.push_back(info.m_name);
    }

    // Adjust width for biggest entry
    auto biggest_text_width = name_size.x;
    // auto biggest_text_width = name_size_width;
    auto keybind_position_y = padding + name_size.y + padding + padding;

    // render
    for (auto i = 0u; i < spectators.size(); i++) {
        // Get current keybind text size
        const auto keybind_size = render::measure_text(font::verdana_12, spectators.at(i));

        // Check if bigger one
        biggest_text_width = std::fmaxf(biggest_text_width, keybind_size.x);

        // Render keybind name
        render::text(pos.x + padding, pos.y + keybind_position_y, font::verdana_12, spectators.at(i), col_text, EFFECT_OUTLINE);

        // Calculating position for our next keybind
        keybind_position_y += keybind_size.y + padding;
    }

    auto bg_size = vec2(padding + biggest_text_width + padding,
                              padding + name_size.y + padding);

    render::rect(pos.x, pos.y, bg_size.x, bg_size.y, col_background); // Background
    render::rect(pos.x, pos.y, bg_size.x, 2, col_accent); // Accent line
    render::text(pos.x + (bg_size.x * 0.5f), pos.y + padding, font::verdana_12, name, col_text, ALIGN_CENTER_X | EFFECT_OUTLINE); // Element name
}

pseudo
 
Статус
В этой теме нельзя размещать новые ответы.
Назад
Сверху Снизу