Подведи собственные итоги года совместно с YOUGAME и забери ценные призы! Перейти

Как пофиксить бинды?

who are you dot idk
Пользователь
Пользователь
Статус
Оффлайн
Регистрация
24 Ноя 2019
Сообщения
390
Реакции
119
Проблема в том, что если я сажусь на фд и нажимаю какую-нибудь другую клавишу на клавиатуре, бинд перестаёт воркать.
1-cpp ; 2-h
C++:
Expand Collapse Copy
bool c_keybind::update()
{
    if (should_render)
        if (!should_render())
            return false;
    c_child* c = (c_child*)child;
    if (!c) return false;
    auto wnd = (c_window*)c->get_parent();
    if (!wnd) return false;
    if (wnd->g_active_element != this && wnd->g_active_element != nullptr) return true;
    auto pos = c->get_cursor_position();
    bool h = hovered();

    if (wnd->get_active_tab_index() != this->tab && wnd->get_tabs().size() > 0)
        return false;
    if (h) wnd->g_hovered_element = this;
    // bullshit animations
    if (h) {
        if (animation < 1.f) animation += animation_speed;
    }
    else {
        if (animation > 0.f) animation -= animation_speed;
    }

    bind->type = clamp<unsigned short>(bind->type, 0, 4);
    bind->key = clamp<unsigned short>(bind->key, 0, 255);

    animation = clamp(animation, 0.f, 1.f);
  
    if (binder.active) {
        for (auto i = 0; i < 256; i++) {
            if (wnd->key_updated(i)) {
                if (i == VK_ESCAPE) {
                    bind->key = 0;
                    binder.active = false;
                    wnd->g_active_element = nullptr;
                    return true;
                }
                else {
                    bind->key = i;
                    binder.active = false;
                    wnd->g_active_element = nullptr;
                    return true;
                }
            }
        }

        return true;
    }


    if (h && c->hovered() && wnd->left_click()) {
        binder.open = true;
        wnd->g_active_element = this;
        return true;
    }
    if (binder.open) {
        auto size = Vector2D(g_size, 20);
        pos.y += size.y;
        h = g_mouse.x >= pos.x && g_mouse.y >= pos.y
            && g_mouse.x <= pos.x + size.x && g_mouse.y < pos.y + size.y;
        if (wnd->is_click() && h) {
            binder.open = false;
            wnd->g_active_element = nullptr;
            wnd->reset_mouse();
            return true;
        }
        h = g_mouse.x >= pos.x && g_mouse.y >= pos.y
            && g_mouse.x <= pos.x + size.x && g_mouse.y < pos.y + size.y * (binder.elements.size() + 1);
        if ((wnd->is_click() || wnd->left_click()) && !h) {
            binder.open = false;
            wnd->g_active_element = nullptr;
            wnd->reset_mouse();
            return true;
        }
        for (size_t i = 0; i < binder.elements.size(); i++) {
            pos.y += 20;
            h = g_mouse.x >= pos.x && g_mouse.y >= pos.y
                && g_mouse.x <= pos.x + size.x && g_mouse.y < pos.y + size.y;
            if (h) {
                if (binder.animations[i] < 1.f) binder.animations[i] += animation_speed;
            }
            else
            {
                if (binder.animations[i] > 0.f) binder.animations[i] -= animation_speed;
            }
            if (binder.animations[i] > 1.f) binder.animations[i] = 1.f;
            else if (binder.animations[i] < 0.f) binder.animations[i] = 0.f;
            if (wnd->is_click() && h) {
                bind->type = i;
                binder.open = false;
                wnd->g_active_element = nullptr;
                wnd->reset_mouse();
                return true;
            }
        }
        wnd->g_active_element = this;
    }
    else {
        auto size = Vector2D(g_size, 20);
        h = g_mouse.x > pos.x && g_mouse.y > pos.y
            && g_mouse.x < pos.x + size.x && g_mouse.y < pos.y + size.y;
        if (h && c->hovered() && wnd->is_click() && bind->type > 0) {
            binder.active = true;
            wnd->g_active_element = this;
            return true;
        }
        if (h) {
            if (binder.animation < 1.f) binder.animation += animation_speed;
        }
        else {
            if (binder.animation > 0.f) binder.animation -= animation_speed;
        }
        if (binder.animation > 1.f) binder.animation = 1.f;
        else if (binder.animation < 0.f) binder.animation = 0.f;
    }

    return true;
}

bool c_keybind::hovered()
{
    if (should_render)
        if (!should_render())
            return false;
    c_child* c = (c_child*)child;
    if (!c->hovered())
        return false;
    auto pos = c->get_cursor_position();
    auto alpha = (int)(c->get_transparency() * 2.55f);
    auto size = Vector2D(g_size, 20);
    return g_mouse.x > pos.x && g_mouse.y > pos.y
        && g_mouse.x < pos.x + size.x && g_mouse.y < pos.y + size.y;
}

void c_keybind::render() {
    if (should_render)
        if (!should_render())
            return;
    c_child* c = (c_child*)child;
    auto pos = c->get_cursor_position();
    auto wnd = (c_window*)c->get_parent();
    auto size = Vector2D(g_size, 20);
    if (!wnd) return;
    if (wnd->get_active_tab_index() != this->tab
        && wnd->get_tabs().size() > 0) return;

    auto alpha = (int)(wnd->get_transparency() * 2.55f);
    auto clr = color_t(40 + animation * 10.f, 40 + animation * 10.f, 40 + animation * 10.f, alpha);
    auto clr2 = color_t(40 - animation * 10.f, 40 - animation * 10.f, 40 - animation * 10.f, alpha);

    g_Render->filled_rect_gradient(pos.x, pos.y, size.x, size.y,
        clr2, clr2,
        clr, clr);
    g_Render->Rect(pos.x - 1, pos.y - 1, size.x + 2, size.y + 2,
        color_t(0, 0, 0, alpha));
    string format = label + ": %s";
    g_Render->DrawString(pos.x + size.x / 2, pos.y + size.y / 2, binder.active ?
        color_t(200 + 55.f * animation, 100 + 50.f * animation, 25.f - 25.f * animation, alpha) :
        color_t(200 + 55.f * animation, 200 + 55.f * animation, 200 + 55.f * animation, alpha),
        render::centered_x | render::centered_y, fonts::menu_desc, format.c_str(), KeyStrings[bind->key].c_str());


    if (binder.open) {

        pos.y += size.y;
        auto size = Vector2D(g_size, 20);
        g_Render->Rect(pos.x - 1, pos.y - 1, size.x + 2, (size.y * (binder.elements.size() + 1)) + 2, color_t(0, 0, 0, alpha));
        g_Render->FilledRect(pos.x, pos.y, size.x, size.y,
            color_t(25.f, 25.f, 25.f, alpha));

        auto base = ImVec2(pos.x + size.x - 10, pos.y + size.y / 2);
        g_Render->_drawList->AddTriangleFilled(
            ImVec2(base.x - 3, base.y + 2), ImVec2(base.x + 3, base.y + 2), ImVec2(base.x, base.y - 4), color_t(255, 255, 255, alpha).u32());

        g_Render->DrawString(pos.x + 10, pos.y + size.y / 2, color_t(255, 255, 255, alpha), render::centered_y,
            fonts::menu_desc, "%s (%s)", KeyStrings[bind->key].c_str(), binder.elements[bind->type].c_str());

        for (size_t i = 0; i < binder.elements.size(); i++) {
            pos.y += size.y;
            g_Render->FilledRect(pos.x, pos.y, size.x, size.y,
                color_t(25.f + 15.f * binder.animations[i], 25.f + 15.f * binder.animations[i], 25.f + 15.f * binder.animations[i], alpha));

            auto clr2 = color_t(200 + binder.animations[i] * 55.f, 200 + binder.animations[i] * 55.f, 200 + binder.animations[i] * 55.f, alpha);
            g_Render->DrawString(pos.x + 10, pos.y + size.y / 2, clr2, render::centered_y,
                fonts::menu_desc, binder.elements[i].c_str());
        }
        g_Render->DrawLine(pos.x, pos.y + size.y, pos.x + size.x, pos.y + size.y, color_t(0, 0, 0, alpha));
    }
    else {
        auto base = ImVec2(pos.x + size.x - 10, pos.y + size.y / 2);
        g_Render->_drawList->AddTriangleFilled(
            ImVec2(base.x - 4, base.y - 2), ImVec2(base.x + 4, base.y - 2), ImVec2(base.x, base.y + 5), color_t(255, 255, 255, alpha).u32());
    }
}
C++:
Expand Collapse Copy
struct c_bind;
class c_keybind : public c_element {
private:
    string label;
    float animation;
    float reading_animation;
  
    bool(*should_render)();
public:
    c_bind* bind;
    c_keybind(string label, c_bind* bind, bool(*should_render)() = nullptr) {
        this->label = label;
        this->bind = bind;
        this->type = c_elementtype::keybind;
        this->binder.open = false;
        this->bind->key = 0;
        this->bind->type = 0;
        this->binder.active = false;
        this->should_render = should_render;
        for (int i = 0; i < 4; i++)
            binder.animations[i] = 0.f;
        animation = 0.f;
    }
    struct {
        bool open, active;
        float animations[4];
        float animation;
        vector<string> elements = { "always off", "hold", "toggle", "release", "always on" };
    } binder;
    bool update();
    bool hovered();
    void render();
    void change_pointer(void* ptr) { };
    void special_render() {};
    int get_total_offset() {
        if (should_render)
            if (!should_render())
                return 0;
        return 23;
    };
};
 
Последнее редактирование:
Проблема в том, что если я сажусь на фд и нажимаю какую-нибудь другую клавишу на клавиатуре, бинд перестаёт воркать.
1-cpp ; 2-h
C++:
Expand Collapse Copy
bool c_keybind::update()
{
    if (should_render)
        if (!should_render())
            return false;
    c_child* c = (c_child*)child;
    if (!c) return false;
    auto wnd = (c_window*)c->get_parent();
    if (!wnd) return false;
    if (wnd->g_active_element != this && wnd->g_active_element != nullptr) return true;
    auto pos = c->get_cursor_position();
    bool h = hovered();

    if (wnd->get_active_tab_index() != this->tab && wnd->get_tabs().size() > 0)
        return false;
    if (h) wnd->g_hovered_element = this;
    // bullshit animations
    if (h) {
        if (animation < 1.f) animation += animation_speed;
    }
    else {
        if (animation > 0.f) animation -= animation_speed;
    }

    bind->type = clamp<unsigned short>(bind->type, 0, 4);
    bind->key = clamp<unsigned short>(bind->key, 0, 255);

    animation = clamp(animation, 0.f, 1.f);
 
    if (binder.active) {
        for (auto i = 0; i < 256; i++) {
            if (wnd->key_updated(i)) {
                if (i == VK_ESCAPE) {
                    bind->key = 0;
                    binder.active = false;
                    wnd->g_active_element = nullptr;
                    return true;
                }
                else {
                    bind->key = i;
                    binder.active = false;
                    wnd->g_active_element = nullptr;
                    return true;
                }
            }
        }

        return true;
    }


    if (h && c->hovered() && wnd->left_click()) {
        binder.open = true;
        wnd->g_active_element = this;
        return true;
    }
    if (binder.open) {
        auto size = Vector2D(g_size, 20);
        pos.y += size.y;
        h = g_mouse.x >= pos.x && g_mouse.y >= pos.y
            && g_mouse.x <= pos.x + size.x && g_mouse.y < pos.y + size.y;
        if (wnd->is_click() && h) {
            binder.open = false;
            wnd->g_active_element = nullptr;
            wnd->reset_mouse();
            return true;
        }
        h = g_mouse.x >= pos.x && g_mouse.y >= pos.y
            && g_mouse.x <= pos.x + size.x && g_mouse.y < pos.y + size.y * (binder.elements.size() + 1);
        if ((wnd->is_click() || wnd->left_click()) && !h) {
            binder.open = false;
            wnd->g_active_element = nullptr;
            wnd->reset_mouse();
            return true;
        }
        for (size_t i = 0; i < binder.elements.size(); i++) {
            pos.y += 20;
            h = g_mouse.x >= pos.x && g_mouse.y >= pos.y
                && g_mouse.x <= pos.x + size.x && g_mouse.y < pos.y + size.y;
            if (h) {
                if (binder.animations[i] < 1.f) binder.animations[i] += animation_speed;
            }
            else
            {
                if (binder.animations[i] > 0.f) binder.animations[i] -= animation_speed;
            }
            if (binder.animations[i] > 1.f) binder.animations[i] = 1.f;
            else if (binder.animations[i] < 0.f) binder.animations[i] = 0.f;
            if (wnd->is_click() && h) {
                bind->type = i;
                binder.open = false;
                wnd->g_active_element = nullptr;
                wnd->reset_mouse();
                return true;
            }
        }
        wnd->g_active_element = this;
    }
    else {
        auto size = Vector2D(g_size, 20);
        h = g_mouse.x > pos.x && g_mouse.y > pos.y
            && g_mouse.x < pos.x + size.x && g_mouse.y < pos.y + size.y;
        if (h && c->hovered() && wnd->is_click() && bind->type > 0) {
            binder.active = true;
            wnd->g_active_element = this;
            return true;
        }
        if (h) {
            if (binder.animation < 1.f) binder.animation += animation_speed;
        }
        else {
            if (binder.animation > 0.f) binder.animation -= animation_speed;
        }
        if (binder.animation > 1.f) binder.animation = 1.f;
        else if (binder.animation < 0.f) binder.animation = 0.f;
    }

    return true;
}

bool c_keybind::hovered()
{
    if (should_render)
        if (!should_render())
            return false;
    c_child* c = (c_child*)child;
    if (!c->hovered())
        return false;
    auto pos = c->get_cursor_position();
    auto alpha = (int)(c->get_transparency() * 2.55f);
    auto size = Vector2D(g_size, 20);
    return g_mouse.x > pos.x && g_mouse.y > pos.y
        && g_mouse.x < pos.x + size.x && g_mouse.y < pos.y + size.y;
}

void c_keybind::render() {
    if (should_render)
        if (!should_render())
            return;
    c_child* c = (c_child*)child;
    auto pos = c->get_cursor_position();
    auto wnd = (c_window*)c->get_parent();
    auto size = Vector2D(g_size, 20);
    if (!wnd) return;
    if (wnd->get_active_tab_index() != this->tab
        && wnd->get_tabs().size() > 0) return;

    auto alpha = (int)(wnd->get_transparency() * 2.55f);
    auto clr = color_t(40 + animation * 10.f, 40 + animation * 10.f, 40 + animation * 10.f, alpha);
    auto clr2 = color_t(40 - animation * 10.f, 40 - animation * 10.f, 40 - animation * 10.f, alpha);

    g_Render->filled_rect_gradient(pos.x, pos.y, size.x, size.y,
        clr2, clr2,
        clr, clr);
    g_Render->Rect(pos.x - 1, pos.y - 1, size.x + 2, size.y + 2,
        color_t(0, 0, 0, alpha));
    string format = label + ": %s";
    g_Render->DrawString(pos.x + size.x / 2, pos.y + size.y / 2, binder.active ?
        color_t(200 + 55.f * animation, 100 + 50.f * animation, 25.f - 25.f * animation, alpha) :
        color_t(200 + 55.f * animation, 200 + 55.f * animation, 200 + 55.f * animation, alpha),
        render::centered_x | render::centered_y, fonts::menu_desc, format.c_str(), KeyStrings[bind->key].c_str());


    if (binder.open) {

        pos.y += size.y;
        auto size = Vector2D(g_size, 20);
        g_Render->Rect(pos.x - 1, pos.y - 1, size.x + 2, (size.y * (binder.elements.size() + 1)) + 2, color_t(0, 0, 0, alpha));
        g_Render->FilledRect(pos.x, pos.y, size.x, size.y,
            color_t(25.f, 25.f, 25.f, alpha));

        auto base = ImVec2(pos.x + size.x - 10, pos.y + size.y / 2);
        g_Render->_drawList->AddTriangleFilled(
            ImVec2(base.x - 3, base.y + 2), ImVec2(base.x + 3, base.y + 2), ImVec2(base.x, base.y - 4), color_t(255, 255, 255, alpha).u32());

        g_Render->DrawString(pos.x + 10, pos.y + size.y / 2, color_t(255, 255, 255, alpha), render::centered_y,
            fonts::menu_desc, "%s (%s)", KeyStrings[bind->key].c_str(), binder.elements[bind->type].c_str());

        for (size_t i = 0; i < binder.elements.size(); i++) {
            pos.y += size.y;
            g_Render->FilledRect(pos.x, pos.y, size.x, size.y,
                color_t(25.f + 15.f * binder.animations[i], 25.f + 15.f * binder.animations[i], 25.f + 15.f * binder.animations[i], alpha));

            auto clr2 = color_t(200 + binder.animations[i] * 55.f, 200 + binder.animations[i] * 55.f, 200 + binder.animations[i] * 55.f, alpha);
            g_Render->DrawString(pos.x + 10, pos.y + size.y / 2, clr2, render::centered_y,
                fonts::menu_desc, binder.elements[i].c_str());
        }
        g_Render->DrawLine(pos.x, pos.y + size.y, pos.x + size.x, pos.y + size.y, color_t(0, 0, 0, alpha));
    }
    else {
        auto base = ImVec2(pos.x + size.x - 10, pos.y + size.y / 2);
        g_Render->_drawList->AddTriangleFilled(
            ImVec2(base.x - 4, base.y - 2), ImVec2(base.x + 4, base.y - 2), ImVec2(base.x, base.y + 5), color_t(255, 255, 255, alpha).u32());
    }
}
C++:
Expand Collapse Copy
struct c_bind;
class c_keybind : public c_element {
private:
    string label;
    float animation;
    float reading_animation;
 
    bool(*should_render)();
public:
    c_bind* bind;
    c_keybind(string label, c_bind* bind, bool(*should_render)() = nullptr) {
        this->label = label;
        this->bind = bind;
        this->type = c_elementtype::keybind;
        this->binder.open = false;
        this->bind->key = 0;
        this->bind->type = 0;
        this->binder.active = false;
        this->should_render = should_render;
        for (int i = 0; i < 4; i++)
            binder.animations[i] = 0.f;
        animation = 0.f;
    }
    struct {
        bool open, active;
        float animations[4];
        float animation;
        vector<string> elements = { "always off", "hold", "toggle", "release", "always on" };
    } binder;
    bool update();
    bool hovered();
    void render();
    void change_pointer(void* ptr) { };
    void special_render() {};
    int get_total_offset() {
        if (should_render)
            if (!should_render())
                return 0;
        return 23;
    };
};
проблема не в биндах, а в тебе... в фд баг бтв нехер пастить говно в виаве
 
кинь код фд
а кинешь сурс вообще сам пофикшу))
Давай не надо твоих кидай сурс
Держи код фд
C++:
Expand Collapse Copy
void FakeDuck(bool& send_packet)
{
    if (csgo->cmd->buttons & IN_JUMP || !(csgo->local->GetFlags() & FL_ONGROUND) || !vars.antiaim.enable) {
        csgo->fake_duck = false;
        return;
    }
    csgo->cmd->buttons |= IN_BULLRUSH;

    int choke =/* csgo->game_rules->IsValveDS() ? 6 :*/ 14;

    if (vars.antiaim.fakeduck->active)
    {
        csgo->fake_duck = true;

        if (csgo->client_state->iChokedCommands <= choke / 2)
        {
            csgo->cmd->buttons &= ~IN_DUCK;

            if (csgo->client_state->iChokedCommands > (choke / 3) + 1)
                csgo->stand = true; // костыль с зевса чтобы по сприду не срать
            else
                csgo->stand = false;
        }
        else
        {
            csgo->cmd->buttons |= IN_DUCK;
            csgo->stand = false;
        }

        if (csgo->client_state->iChokedCommands < choke)
            send_packet = false;                                // choke
        else
            send_packet = true;
    }
    else {
        csgo->fake_duck = false;
        csgo->stand = false;
    }
}
 
Скрытое содержимое
замени на мой если не будет ворк то попробуй скопировать из ориг виава кейбинд и чекнуть
Как я понял фд тут ни при чем. Виноваты кейбинды. Только от куда мне их спастить, если у 1 лика сурсов его нету? (вроде как)
 
Назад
Сверху Снизу