/*
* CSB Thunderstorm
* Copyright (C) 2026 counter-strike-boost.com
*
* A weather ambience layer. On a periodic schedule (frequency scaled by an
* intensity cvar) the sky flashes: a brief white ScreenFade plus a bright
* TE_DLIGHT above the player, followed by a thunder sound. Admins can trigger a
* flash on demand. Purely cosmetic; nothing about gameplay changes.
*
* 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 for details.
*/
#include
#include
new const PLUGIN[] = "CSB Thunderstorm"
new const VERSION[] = "1.0.0"
new const AUTHOR[] = "counter-strike-boost.com"
#define THUNDER_SOUND "ambience/thunder_clap.wav"
new g_pEnabled, g_pIntensity
new g_iMsgScreenFade
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_pEnabled = register_cvar("csb_storm_enabled", "1")
g_pIntensity = register_cvar("csb_storm_intensity", "5")
g_iMsgScreenFade = get_user_msgid("ScreenFade")
register_concmd("amx_thunder", "cmdThunder", ADMIN_LEVEL_A, "- trigger a lightning flash now")
scheduleNext()
}
public plugin_precache()
{
precache_sound(THUNDER_SOUND)
}
scheduleNext()
{
new intensity = get_pcvar_num(g_pIntensity)
if (intensity < 1)
intensity = 1
else if (intensity > 10)
intensity = 10
new Float:base = 30.0 - float(intensity) * 2.5
new Float:delay = base + float(random_num(0, 8))
if (delay < 3.0)
delay = 3.0
set_task(delay, "taskStorm", 7788)
}
public taskStorm()
{
if (get_pcvar_num(g_pEnabled))
strike()
scheduleNext()
}
public cmdThunder(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
strike()
new name[32]
get_user_name(id, name, charsmax(name))
client_print(0, print_chat, "[CSB] %s summoned a thunderstrike.", name)
return PLUGIN_HANDLED
}
strike()
{
new players[32], num
get_players(players, num, "c")
for (new i = 0; i < num; i++)
{
new id = players[i]
/* white flash */
message_begin(MSG_ONE, g_iMsgScreenFade, _, id)
write_short(1 << 10)
write_short(1 << 8)
write_short(0)
write_byte(255)
write_byte(255)
write_byte(255)
write_byte(160)
message_end()
if (is_user_alive(id))
{
new origin[3]
get_user_origin(id, origin)
message_begin(MSG_ONE, SVC_TEMPENTITY, _, id)
write_byte(TE_DLIGHT)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2] + 300)
write_byte(40)
write_byte(255)
write_byte(255)
write_byte(255)
write_byte(4)
write_byte(40)
message_end()
}
}
set_task(0.6, "taskThunder", 7799)
}
public taskThunder()
{
new players[32], num
get_players(players, num, "ch")
for (new i = 0; i < num; i++)
client_cmd(players[i], "play %s", THUNDER_SOUND)
}