/*
* CSB Spray ID
* Copyright (C) 2026 counter-strike-boost.com
*
* Announces who sprayed a logo. The spray action fires impulse 201, which this
* plugin catches; it traces from the player's aim to the wall to locate the
* decal, then prints the sprayer's name to everyone (or only to admins). A
* per-player cooldown stops spray spam from flooding chat.
*
* Inspired by the classic Spray Detector plugins. Independent GPL
* re-implementation.
*
* 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 Spray ID"
new const VERSION[] = "1.0.0"
new const AUTHOR[] = "counter-strike-boost.com"
new g_pEnabled, g_pAdminsOnly, g_pCooldown
new Float:g_fLastSpray[33]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_pEnabled = register_cvar("csb_sprayid_enabled", "1")
g_pAdminsOnly = register_cvar("csb_sprayid_adminsonly", "0")
g_pCooldown = register_cvar("csb_sprayid_cooldown", "3.0")
register_impulse(201, "impulseSpray")
}
public client_putinserver(id)
{
g_fLastSpray[id] = 0.0
}
public impulseSpray(id)
{
if (!get_pcvar_num(g_pEnabled) || !is_user_connected(id))
return PLUGIN_CONTINUE
new Float:cd = get_pcvar_float(g_pCooldown)
if (get_gametime() - g_fLastSpray[id] < cd)
return PLUGIN_CONTINUE
g_fLastSpray[id] = get_gametime()
new name[32]
get_user_name(id, name, charsmax(name))
/* aim end point traced to the world */
new origin[3]
get_user_origin(id, origin, 3)
new msg[128]
formatex(msg, charsmax(msg), "^x04[Spray]^x01 %s sprayed a logo at (%d %d %d).", name, origin[0], origin[1], origin[2])
if (get_pcvar_num(g_pAdminsOnly))
{
new players[32], num
get_players(players, num, "ch")
for (new i = 0; i < num; i++)
{
if (get_user_flags(players[i]) & ADMIN_KICK)
client_print(players[i], print_chat, "%s", msg)
}
}
else
{
client_print(0, print_chat, "%s", msg)
}
return PLUGIN_CONTINUE
}