Skip to content
View in the app

A better way to browse. Learn more.

Learn more

kit-coverage/addons/amxmodx/scripting/olds_kits.sma

olds_kits.sma
149 lines · 4.3 KB · Pawn (AMX Mod X)
Raw
/*
 * Kit Coverage (olds.ro workshop card AMX-024)
 *
 * A living Counter-Terrorist types /kits in chat during the freeze time and
 * gets, privately, how many living CTs carry a defuse kit, for example
 * "Defuse kits: 3 of 5 living CTs". It helps the team decide who buys a kit
 * before the round starts. The count is made fresh on every request, so a kit
 * bought a moment ago is counted.
 *
 * The command exists only on bomb maps (maps with a func_bomb_target or an
 * info_bomb_target); on other maps /kits is ordinary chat. A Terrorist, a
 * spectator or a dead CT gets a short refusal and no numbers.
 *
 * Chat command (chat and team chat, any letter case):
 *   /kits    your team's defuse kit count, to you only
 *
 * Cvars (in configs/plugins/olds_kits.cfg, written with the defaults on the
 * first start if the file is missing):
 *   olds_kits_freeze 1   1 = /kits works only in the freeze time,
 *                        0 = it works for the whole round.
 *
 * Texts are in data/lang/olds_kits.txt.
 *
 * Requires AMX Mod X 1.10 with the cstrike and fakemeta modules (both ship
 * with AMX Mod X). No ReAPI. Written and tested on AMX Mod X 1.10.0.5490,
 * ReHLDS 3.15.0.896 and ReGameDLL_CS 5.30.0.814.
 *
 * Copyright (C) 2026 alexit (olds.ro workshop)
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * 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/>.
 */

#include <amxmodx>
#include <cstrike>
#include <fakemeta>

#pragma semicolon 1

new const PLUGIN_NAME[] = "Kit Coverage";
new const PLUGIN_VERSION[] = "1.0.0";
new const PLUGIN_AUTHOR[] = "alexit (olds.ro)";

new g_freezeOnly;    // olds_kits_freeze

// The map has a bomb target, so defuse kits matter.
new bool:g_bombMap;

// The freeze time of the current round is running.
new bool:g_freezeTime;

public plugin_init()
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
	register_dictionary("olds_kits.txt");

	bind_pcvar_num(create_cvar("olds_kits_freeze", "1", FCVAR_NONE,
		"1 = /kits works only in the freeze time, 0 = for the whole round",
		true, 0.0, true, 1.0), g_freezeOnly);

	AutoExecConfig(true, "olds_kits");

	// Brush and point bomb targets both make a bomb map.
	g_bombMap = engfunc(EngFunc_FindEntityByString, -1, "classname", "func_bomb_target") > 0
		|| engfunc(EngFunc_FindEntityByString, -1, "classname", "info_bomb_target") > 0;

	// On other maps /kits stays ordinary chat.
	if (!g_bombMap)
		return;

	register_clcmd("say", "cmd_say");
	register_clcmd("say_team", "cmd_say");

	// The freeze time starts with every new round and ends at Round_Start.
	register_event("HLTV", "ev_new_round", "a", "1=0", "2=0");
	register_logevent("ev_round_start", 2, "1=Round_Start");
}

public ev_new_round()
{
	g_freezeTime = true;
}

public ev_round_start()
{
	g_freezeTime = false;
}

public cmd_say(id)
{
	new text[16];

	// Chat sends the whole line as one argument; a line that fills the buffer
	// is longer than the command.
	if (read_argc() != 2 || read_argv(1, text, charsmax(text)) >= charsmax(text))
		return PLUGIN_CONTINUE;

	trim(text);

	if (!equali(text, "/kits"))
		return PLUGIN_CONTINUE;

	if (is_user_connected(id))
		answer(id);

	// The answer is private, so the request is not shown in chat either.
	return PLUGIN_HANDLED;
}

answer(id)
{
	// Team, life and the round are checked again on every request.
	if (cs_get_user_team(id) != CS_TEAM_CT)
	{
		client_print_color(id, print_team_default, "%L", id, "KITS_CT_ONLY");
		return;
	}

	if (!is_user_alive(id))
	{
		client_print_color(id, print_team_default, "%L", id, "KITS_ALIVE_ONLY");
		return;
	}

	if (g_freezeOnly && !g_freezeTime)
	{
		client_print_color(id, print_team_default, "%L", id, "KITS_FREEZE_ONLY");
		return;
	}

	new players[MAX_PLAYERS], count, withKit;
	get_players(players, count, "ae", "CT");

	for (new i = 0; i < count; i++)
	{
		if (cs_get_user_defuse(players[i]))
			withKit++;
	}

	client_print_color(id, print_team_default, "%L", id, "KITS_COUNT", withKit, count);
}

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.