Skip to content
View in the app

A better way to browse. Learn more.

Learn more

privileged-auto-bunnyhop/addons/amxmodx/scripting/olds_autobhop.sma

olds_autobhop.sma
132 lines · 4.6 KB · Pawn (AMX Mod X)
Raw
/*
 * Privileged Auto Bunnyhop (olds.ro workshop card LIB-0052)
 * Copyright (C) 2026 daemon (olds.ro)
 *
 * This program is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details: <https://www.gnu.org/licenses/>.
 *
 * Players with the olds_ab_flag access flag(s) bunny-hop by holding the jump key: in
 * PreThink, while IN_JUMP is held and they stand on the ground, IN_JUMP is removed from
 * pev_oldbuttons, so the game sees a fresh press and jumps again. Nothing else is changed
 * (no speed, no gravity). The flag is read when the player enters the server and again at
 * every spawn, so a lost flag stops the feature at the next respawn. say /abh turns it off
 * or on for oneself. In water (waist deep or more) nothing is forced unless olds_ab_water 1.
 */
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <reapi>

#define PLUGIN  "Privileged Auto Bunnyhop"
#define VERSION "1.0.0"
#define AUTHOR  "daemon (olds.ro)"

new g_cvarFlag, g_default, g_water
new bool:g_allowed[MAX_PLAYERS + 1]
new bool:g_on[MAX_PLAYERS + 1]
new g_forced[MAX_PLAYERS + 1]

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_dictionary("olds_autobhop.txt")
    g_cvarFlag = create_cvar("olds_ab_flag", "b", FCVAR_NONE, "Access flag(s) that allow auto bunnyhop (all of them are needed)")
    bind_pcvar_num(create_cvar("olds_ab_default", "1", FCVAR_NONE, "1 = auto bunnyhop is on when an allowed player joins", true, 0.0, true, 1.0), g_default)
    bind_pcvar_num(create_cvar("olds_ab_water", "0", FCVAR_NONE, "1 = also chain jumps in water (waist deep or more)", true, 0.0, true, 1.0), g_water)
    AutoExecConfig(true, "olds_autobhop")
    register_clcmd("say /abh", "cmd_toggle")
    register_clcmd("say_team /abh", "cmd_toggle")
    register_concmd("amx_abh_status", "cmd_status", ADMIN_KICK, "- who may auto bunnyhop and who has it on")
    RegisterHookChain(RG_CBasePlayer_PreThink, "on_prethink", false)
    RegisterHookChain(RG_CBasePlayer_Spawn, "on_spawn_post", true)
}

bool:has_flag_now(id)
{
    new flags[24]
    get_pcvar_string(g_cvarFlag, flags, charsmax(flags))
    new need = read_flags(flags)
    if (!need)
        return false
    return (get_user_flags(id) & need) == need
}

public client_putinserver(id)
{
    g_allowed[id] = has_flag_now(id)
    g_on[id] = g_default != 0
    g_forced[id] = 0
}

public client_disconnected(id)
{
    g_allowed[id] = false
    g_on[id] = false
}

public on_spawn_post(id)
{
    if (!is_user_connected(id))
        return
    new bool:was = g_allowed[id]
    g_allowed[id] = has_flag_now(id)
    if (was && !g_allowed[id])
        client_print(id, print_chat, "%L", id, "ABH_LOST")
}

public cmd_toggle(id)
{
    if (!g_allowed[id])
    {
        client_print(id, print_chat, "%L", id, "ABH_NO_ACCESS")
        return PLUGIN_HANDLED
    }
    g_on[id] = !g_on[id]
    if (g_on[id])
        client_print(id, print_chat, "%L", id, "ABH_ON")
    else
        client_print(id, print_chat, "%L", id, "ABH_OFF")
    return PLUGIN_HANDLED
}

public on_prethink(id)
{
    if (!g_allowed[id] || !g_on[id] || !is_user_alive(id))
        return HC_CONTINUE
    if (!(get_entvar(id, var_button) & IN_JUMP))
        return HC_CONTINUE
    if (!(get_entvar(id, var_flags) & FL_ONGROUND))
        return HC_CONTINUE
    if (!g_water && get_entvar(id, var_waterlevel) >= 2)
        return HC_CONTINUE
    new old = get_entvar(id, var_oldbuttons)
    if (old & IN_JUMP)
    {
        set_entvar(id, var_oldbuttons, old & ~IN_JUMP)
        g_forced[id]++
    }
    return HC_CONTINUE
}

public cmd_status(id, level, cid)
{
    if (!cmd_access(id, level, cid, 1))
        return PLUGIN_HANDLED
    new flags[24], name[MAX_NAME_LENGTH], own[24]
    get_pcvar_string(g_cvarFlag, flags, charsmax(flags))
    console_print(id, "[ABH] flag ^"%s^", default %d, water %d", flags, g_default, g_water)
    for (new p = 1; p <= MaxClients; p++)
    {
        if (!is_user_connected(p))
            continue
        get_user_name(p, name, charsmax(name))
        get_flags(get_user_flags(p), own, charsmax(own))
        console_print(id, "[ABH]   %s: flags ^"%s^", allowed %d, on %d, forced hops %d, waterlevel %d", name, own, g_allowed[p], g_on[p],
            g_forced[p], get_entvar(p, var_waterlevel))
    }
    return PLUGIN_HANDLED
}

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.