Promuj serwer
Black Friday zaczyna sie jutro 50% taniej: miejsce na Master Serverze i lista Client, z PREMIUM DOZYWOTNIO
02 Godz 49 Min 12 Sek
csb-random-events / addons / amxmodx / scripting / csb_random_events.sma
183 lines 4 KiB Pawn Raw Permalink History
/*
 * CSB Random Fun Events
 * Copyright (C) 2026 counter-strike-boost.com
 *
 * Every round there is a chance for a random fun event to fire. Each event is a
 * small apply/revert pair applied to every player and cleanly reverted when the
 * round ends: low gravity, giant players (model scale), hyper speed, all-knife
 * combat, or a rocket-slap party that launches everyone into the air. The event
 * is announced in chat and re-applied to anyone who spawns while it is active.
 *
 * 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 <fakemeta>
#include <fun>

new const PLUGIN[] = "CSB Random Fun Events"
new const VERSION[] = "1.0.0"
new const AUTHOR[]  = "counter-strike-boost.com"

enum (+= 1)
{
    EV_NONE = 0,
    EV_LOWGRAV,
    EV_GIANTS,
    EV_SPEED,
    EV_KNIVES,
    EV_ROCKET
}

#define EV_COUNT 5

new const g_szEventName[][] =
{
    "",
    "LOW GRAVITY",
    "GIANTS",
    "HYPER SPEED",
    "KNIVES ONLY",
    "ROCKET SLAP PARTY"
}

new g_pEnabled, g_pChance
new g_iEvent
new g_iHudSync

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

    g_pEnabled = register_cvar("csb_events_enabled", "1")
    g_pChance  = register_cvar("csb_events_chance", "33")

    register_logevent("eventRoundStart", 2, "1=Round_Start")
    register_logevent("eventRoundEnd", 2, "1=Round_End")
    register_event("ResetHUD", "eventSpawn", "b")

    g_iHudSync = CreateHudSyncObj()
}

public eventRoundStart()
{
    if (g_iEvent != EV_NONE)
        endEvent()

    if (!get_pcvar_num(g_pEnabled))
        return

    if (random_num(1, 100) > get_pcvar_num(g_pChance))
        return

    g_iEvent = random_num(1, EV_COUNT)

    client_print(0, print_chat, "[CSB] Random event: %s!", g_szEventName[g_iEvent])

    set_hudmessage(255, 160, 0, -1.0, 0.20, 0, 0.0, 5.0, 0.2, 0.5, -1)
    ShowSyncHudMsg(0, g_iHudSync, "EVENT: %s", g_szEventName[g_iEvent])

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

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

    if (g_iEvent == EV_ROCKET)
        set_task(2.5, "taskRocket", 4455, _, _, "b")
}

public eventSpawn(id)
{
    if (g_iEvent != EV_NONE && is_user_alive(id))
        applyToPlayer(id)
}

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

    switch (g_iEvent)
    {
        case EV_LOWGRAV: set_user_gravity(id, 0.35)
        case EV_GIANTS:
        {
            set_pev(id, pev_scale, 1.6)
            set_user_health(id, 150)
        }
        case EV_SPEED: set_user_maxspeed(id, 500.0)
        case EV_KNIVES:
        {
            strip_user_weapons(id)
            give_item(id, "weapon_knife")
        }
    }
}

revertPlayer(id)
{
    if (!is_user_connected(id))
        return

    set_user_gravity(id, 1.0)
    set_pev(id, pev_scale, 1.0)

    if (is_user_alive(id))
        set_user_maxspeed(id, 250.0)
}

public eventRoundEnd()
{
    endEvent()
}

endEvent()
{
    if (g_iEvent == EV_NONE)
        return

    new was = g_iEvent
    g_iEvent = EV_NONE

    for (new id = 1; id <= 32; id++)
        revertPlayer(id)

    if (was == EV_ROCKET)
        remove_task(4455)
}

public taskRocket()
{
    if (g_iEvent != EV_ROCKET)
    {
        remove_task(4455)
        return
    }

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

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

        static Float:fVel[3]
        pev(id, pev_velocity, fVel)
        fVel[2] += 450.0
        set_pev(id, pev_velocity, fVel)

        client_print(id, print_chat, "[CSB] Wheee!")
    }
}

public plugin_end()
{
    for (new id = 1; id <= 32; id++)
        revertPlayer(id)
}