Promote server
Black Friday Ends in 50% off a Master Server place and the Client list, which comes with LIFETIME PREMIUM
02 Days 07 Hrs 26 Min 08 Sec
See the deals
csb-auras / addons / amxmodx / scripting / csb_auras.sma
191 lines 4.7 KiB Pawn Raw Permalink History
/*
 * CSB Player Auras
 * Copyright (C) 2026 counter-strike-boost.com
 *
 * Gives a player a coloured glow-shell aura chosen from a menu, with an optional
 * pulsing brightness effect driven by a task. The feature is gated behind an
 * access flag (VIP/shop), the aura is re-applied on spawn and cleared on death.
 *
 * 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. It 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 <https://www.gnu.org/licenses/> for details.
 */

#include <amxmodx>
#include <fun>

new const PLUGIN[] = "CSB Player Auras"
new const VERSION[] = "1.0.0"
new const AUTHOR[]  = "counter-strike-boost.com"

#define ACCESS_FLAG ADMIN_LEVEL_H

#define AURA_NONE 0

new const g_szColorName[][] = { "Off", "Red", "Green", "Blue", "Yellow", "Cyan", "Purple", "White" }
new const g_iColorRGB[][3] =
{
    {  0,   0,   0 },
    { 255,  0,   0 },
    {  0,  255,  0 },
    {  0,   0, 255 },
    { 255, 255,  0 },
    {  0,  255,255 },
    { 200,  0, 255 },
    { 255, 255,255 }
}

new g_pEnabled, g_pMinBright, g_pMaxBright
new g_iAura[33]
new bool:g_bPulse[33]
new g_iPhase

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)

    g_pEnabled   = register_cvar("csb_aura_enabled", "1")
    g_pMinBright = register_cvar("csb_aura_minbright", "60")
    g_pMaxBright = register_cvar("csb_aura_maxbright", "180")

    register_clcmd("say /aura", "cmdAura")
    register_clcmd("say_team /aura", "cmdAura")

    register_event("DeathMsg", "eventDeath", "a", "1>0")
    register_event("ResetHUD", "eventSpawn", "b")

    set_task(0.3, "taskPulse", 0, _, _, "b")
}

public client_putinserver(id)
{
    g_iAura[id]  = AURA_NONE
    g_bPulse[id] = false
}

bool:hasAccess(id)
{
    return (get_user_flags(id) & ACCESS_FLAG) != 0
}

public cmdAura(id)
{
    if (!get_pcvar_num(g_pEnabled))
        return PLUGIN_HANDLED

    if (!hasAccess(id))
    {
        client_print(id, print_chat, "[CSB] Auras are a VIP feature.")
        return PLUGIN_HANDLED
    }

    new menu = menu_create("\yCSB Player Aura^n\wPick a colour:", "auraHandler")

    new info[4]
    for (new i = 0; i < sizeof(g_szColorName); i++)
    {
        num_to_str(i, info, charsmax(info))
        menu_additem(menu, g_szColorName[i], info, 0)
    }

    menu_additem(menu, "\wTogglePulse", "99", 0)
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
    menu_display(id, menu, 0)
    return PLUGIN_HANDLED
}

public auraHandler(id, menu, item)
{
    if (item == MENU_EXIT)
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }

    new info[4], name[32], access, callback
    menu_item_getinfo(menu, item, access, info, charsmax(info), name, charsmax(name), callback)
    menu_destroy(menu)

    new choice = str_to_num(info)

    if (choice == 99)
    {
        g_bPulse[id] = !g_bPulse[id]
        client_print(id, print_chat, "[CSB] Aura pulsing %s.", g_bPulse[id] ? "enabled" : "disabled")
        applyAura(id)
        return PLUGIN_HANDLED
    }

    g_iAura[id] = choice

    if (choice == AURA_NONE)
        client_print(id, print_chat, "[CSB] Aura removed.")
    else
        client_print(id, print_chat, "[CSB] Aura set to %s.", g_szColorName[choice])

    applyAura(id)
    return PLUGIN_HANDLED
}

applyAura(id)
{
    if (!is_user_alive(id))
        return

    new a = g_iAura[id]

    if (a == AURA_NONE)
    {
        set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderNormal, 0)
        return
    }

    new amount = g_bPulse[id] ? get_pcvar_num(g_pMaxBright) : get_pcvar_num(g_pMinBright)

    set_user_rendering(id, kRenderFxGlowShell,
        g_iColorRGB[a][0], g_iColorRGB[a][1], g_iColorRGB[a][2],
        kRenderNormal, amount)
}

public eventSpawn(id)
{
    if (is_user_alive(id) && g_iAura[id] != AURA_NONE)
        applyAura(id)
}

public eventDeath()
{
    new victim = read_data(2)

    if (victim >= 1 && victim <= 32)
        set_user_rendering(victim, kRenderFxNone, 0, 0, 0, kRenderNormal, 0)
}

public taskPulse()
{
    g_iPhase = (g_iPhase + 1) % 2

    new lo = get_pcvar_num(g_pMinBright)
    new hi = get_pcvar_num(g_pMaxBright)

    new players[32], num, pid
    get_players(players, num, "a")

    for (new i = 0; i < num; i++)
    {
        pid = players[i]

        if (g_iAura[pid] == AURA_NONE || !g_bPulse[pid])
            continue

        new a = g_iAura[pid]
        new amount = g_iPhase ? hi : lo

        set_user_rendering(pid, kRenderFxGlowShell,
            g_iColorRGB[a][0], g_iColorRGB[a][1], g_iColorRGB[a][2],
            kRenderNormal, amount)
    }
}