Skip to content
View in the app

A better way to browse. Learn more.

Learn more

side-jump/addons/amxmodx/scripting/olds_sidejump.sma

olds_sidejump.sma
186 lines · 5.5 KB · Pawn (AMX Mod X)
Raw
/*
 * Side Jump (olds.ro)
 * Copyright (C) 2026 daemon (olds.ro), written by daemon's plugin agent
 *
 * 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/>.
 *
 * A short sideways dash for soccer maps. +sidejump (bind a key) or say /sidejump sets the
 * player's velocity to his right vector (EngFunc_MakeVectors, v_right; to the left while
 * the move-left key is held) times olds_sj_speed, plus an upward bump of 150, and plays the
 * stock jump sound. Only on the ground unless olds_sj_air is 1, and once per olds_sj_cd
 * seconds; RG_CBasePlayer_PreThink shows the cooldown on the HUD. The dash only sets a
 * velocity, so the engine's own movement stops the player at walls. A new life starts with
 * the cooldown cleared.
 *
 * Cvars: olds_sj_speed 600, olds_sj_cd 2.0, olds_sj_air 0
 * Commands: +sidejump, say /sidejump
 */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <reapi>

#pragma semicolon 0

#define PLUGIN  "Side Jump"
#define VERSION "1.0.0"
#define AUTHOR  "daemon (olds.ro)"

#define BUMP      150.0
#define HUD_EVERY 0.2

new const SND_DASH[] = "player/pl_jump2.wav"

new Float:g_speed
new Float:g_cooldown
new g_air

new g_hud
new Float:g_ready[MAX_PLAYERS + 1]
new Float:g_nextHud[MAX_PLAYERS + 1]
new bool:g_showing[MAX_PLAYERS + 1]

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_dictionary("olds_sidejump.txt")

    bind_pcvar_float(create_cvar("olds_sj_speed", "600", FCVAR_NONE,
        "Sideways speed of the dash", true, 100.0, true, 2000.0), g_speed)
    bind_pcvar_float(create_cvar("olds_sj_cd", "2.0", FCVAR_NONE,
        "Seconds between two dashes", true, 0.0, true, 60.0), g_cooldown)
    bind_pcvar_num(create_cvar("olds_sj_air", "0", FCVAR_NONE,
        "1 allows the dash in the air", true, 0.0, true, 1.0), g_air)
    AutoExecConfig(true, "olds_sidejump")

    register_clcmd("+sidejump", "cmd_sidejump")
    register_clcmd("-sidejump", "cmd_release")
    register_clcmd("say /sidejump", "cmd_say")
    register_clcmd("say_team /sidejump", "cmd_say")

    RegisterHookChain(RG_CBasePlayer_PreThink, "on_prethink", false)
    RegisterHam(Ham_Spawn, "player", "fw_spawn_post", true)

    g_hud = CreateHudSyncObj()
}

public client_putinserver(id)
{
    g_ready[id] = 0.0
    g_showing[id] = false
}

public cmd_release(id)
{
    return PLUGIN_HANDLED
}

public cmd_say(id)
{
    dash(id)
    return PLUGIN_HANDLED_MAIN
}

public cmd_sidejump(id)
{
    dash(id)
    return PLUGIN_HANDLED
}

log_refused(id, const why[])
{
    new name[MAX_NAME_LENGTH]
    get_user_name(id, name, charsmax(name))
    log_amx("%s: side jump refused (%s)", name, why)
}

dash(id)
{
    if (!is_user_alive(id))
        return
    new Float:now = get_gametime()
    if (now < g_ready[id])
    {
        client_print(id, print_center, "%L", id, "SJ_COOLDOWN", g_ready[id] - now)
        log_refused(id, "cooldown")
        return
    }
    if (!g_air && !(pev(id, pev_flags) & FL_ONGROUND))
    {
        client_print(id, print_center, "%L", id, "SJ_GROUND")
        log_refused(id, "in the air")
        return
    }
    new Float:angles[3], Float:right[3], Float:vel[3]
    pev(id, pev_v_angle, angles)
    /* Level the view so the dash is flat whatever the pitch. */
    angles[0] = 0.0
    angles[2] = 0.0
    engfunc(EngFunc_MakeVectors, angles)
    global_get(glb_v_right, right)
    new Float:sign = 1.0
    new buttons = pev(id, pev_button)
    if ((buttons & IN_MOVELEFT) && !(buttons & IN_MOVERIGHT))
        sign = -1.0
    new Float:speed = floatclamp(g_speed, 100.0, 2000.0)
    vel[0] = right[0] * speed * sign
    vel[1] = right[1] * speed * sign
    vel[2] = BUMP
    set_pev(id, pev_velocity, vel)
    set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_ONGROUND)
    emit_sound(id, CHAN_BODY, SND_DASH, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    g_ready[id] = now + floatclamp(g_cooldown, 0.0, 60.0)
    g_nextHud[id] = 0.0
    new name[MAX_NAME_LENGTH]
    get_user_name(id, name, charsmax(name))
    if (sign > 0.0)
        log_amx("%s side jumped right at %.0f u/s", name, speed)
    else
        log_amx("%s side jumped left at %.0f u/s", name, speed)
}

public on_prethink(id)
{
    if (!g_showing[id] && g_ready[id] <= 0.0)
        return HC_CONTINUE
    if (!is_user_alive(id))
        return HC_CONTINUE
    new Float:now = get_gametime()
    if (now < g_nextHud[id])
        return HC_CONTINUE
    g_nextHud[id] = now + HUD_EVERY
    if (now < g_ready[id])
    {
        g_showing[id] = true
        set_hudmessage(255, 180, 60, -1.0, 0.82, 0, 0.0, HUD_EVERY + 0.1, 0.0, 0.0)
        ShowSyncHudMsg(id, g_hud, "%L", id, "SJ_HUD_WAIT", g_ready[id] - now)
        return HC_CONTINUE
    }
    if (g_showing[id])
    {
        g_showing[id] = false
        g_ready[id] = 0.0
        set_hudmessage(80, 255, 80, -1.0, 0.82, 0, 0.0, 1.0, 0.0, 0.3)
        ShowSyncHudMsg(id, g_hud, "%L", id, "SJ_HUD_READY")
    }
    return HC_CONTINUE
}

public fw_spawn_post(id)
{
    if (!is_user_alive(id))
        return HAM_IGNORED
    /* Every life starts with the dash ready. */
    g_ready[id] = 0.0
    g_showing[id] = false
    ClearSyncHud(id, g_hud)
    return HAM_IGNORED
}

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.