# CodeStrike Ban System
**A complete ban system for Counter-Strike 1.6 with a real database, a modern menu, Discord integration and 100+ settings.**
It fully replaces the ban system built into AMX Mod X. Instead of bans written to a text file on a single server, you get a proper database, a full history for every player, a clean in-game menu and live notifications in your Discord.
---
## What it does
When a banned player tries to join, the system matches him by SteamID and IP, kicks him, and prints in his console why he is banned, how much time is left and how to appeal. All of that text is written by you — none of it is baked into the plugin.
When an admin bans somebody, the whole server sees it in chat and on screen, the ban goes into the database, into a log file, and into your Discord channel with the full details.
When a player who already has bans joins, your admins get a warning in chat. You know this person has been punished before, prior to him doing anything.
---
## Main features
### Database
* **SQLite by default** — works out of the box, no database server, nothing to set up
* **MySQL** — one line in the config switches it over
* One MySQL database can serve several servers, so **a ban on one applies on all of them**
* Every query is threaded — the database never freezes your server, not even on a slow connection
* Indexed on SteamID, IP, name and status, so lookups stay fast with tens of thousands of bans
### Bans
* Ban by **SteamID**, **IP** and optionally by **nickname**
* **Temporary and permanent** bans
* Flexible time format: `30`, `30m`, `2h`, `3d`, `1w`, or `0` for permanent
* **Offline bans** by SteamID or IP, without the player being on the server
* A ready list of reasons you edit yourself, plus the option for an admin to type his own
* A reason can carry its own duration, so picking it skips the duration step and goes straight to the confirmation
* Expired bans are flagged automatically
### Menu
* Opens with `amx_banmenu`
* Ban in three steps: player → reason → duration → a confirmation screen with the summary
* Active ban list, full history and search by SteamID, IP or part of a name
* Unban from the menu, or delete a ban record completely — two separate actions, so you decide whether the player keeps his history
* Colour coded: active bans in red, lifted ones in grey, and the duration changes colour with the weight of the punishment
### Discord
* A proper embed on every ban and unban
* Shows player, SteamID, IP, admin, reason, duration, expiry date and ban ID
* Every field can be hidden individually
* Colours, titles, footer, bot name and avatar are all configurable
* The IP can be masked (`85.11.44.xxx`) if you would rather not expose it in Discord
### Ban history
* A full history for every player, kept even after the ban is lifted
* Admins holding a flag of your choice are told in chat when a player with previous bans joins
* **Ban evasion warning** — when somebody joins on a fresh SteamID from an IP that belongs to an active ban, your admins are told. Nobody is banned by it, so a shared connection never costs an innocent player his slot
* Search by SteamID, IP or name, from the menu or from the console
* `amx_banstats` shows the totals, the bans of the last 7 days and which admins hand out the most punishments
### HUD and sound
* An on-screen message on ban and on unban
* Classic HUD or DHUD, your choice
* Colours, position, effects and timings all come from the config
* A ban and unban sound heard by the whole server (nothing is set by default)
### Logs
* A startup banner in the server console showing the active configuration and the current ban counters
* A separate log file with the date in its name
* Every ban, unban and list wipe is recorded — who, whom, when, for how long and why
---
## Commands
| Command | What it does |
|---|---|
| `amx_banmenu` | Opens the main menu |
| `amx_unbanmenu` | Opens the active ban list directly |
| `amx_ban <name\|#userid\|STEAM_ID\|IP> <time> [reason]` | Bans a player |
| `amx_unban <STEAM_ID\|IP\|#banid\|name> [reason]` | Lifts a ban |
| `amx_bans` | Lists the active bans in the console |
| `amx_banhistory <STEAM_ID\|IP\|name>` | The full history of one player |
| `amx_banstats` | Ban totals and the admins who issue the most |
| `amx_bans_reload` | Reloads the settings without a map change |
| `amx_clearbans <active\|all> CONFIRM` | Clears the whole list |
It also takes over `amx_banip` and `amx_addban`, so nothing falls back to the stock AMX Mod X ban system.
Every command sits on its own configurable flag.
---
## Protection against mistakes
The plugin is written so that an admin slip or a broken config cannot do damage.
* **Immunity** — players holding a flag of your choice cannot be banned, except by an admin with a higher flag
* **Time limits** — cap how long a regular admin may ban for, and keep permanent bans for the owner only
* **Confirmation required** — `amx_clearbans` demands an explicit `CONFIRM`, and deleting a single record from the menu asks first. Both sit on their own flag, so nothing is wiped by accident
* **No SQL injection** — nicknames and reasons are filtered before they ever reach a query
* **A broken config breaks nothing** — every value is checked on load and pulled back into a safe range
---
## Requirements
* AMX Mod X **1.9 or newer** — built and tested on 1.10
* The **SQLite** or **MySQL** module (SQLite ships with a standard install)
* The **EasyHttp** module — only if you want the Discord notifications
The plugin comes **compiled and with full source code**.
---
## Installation
1. Upload `codestrike_bans.amxx` to `addons/amxmodx/plugins/`
2. Add it to `plugins.ini` **above** `admincmd.amxx` and `plmenu.amxx`
3. Restart the server
Both config files create themselves on first run in `addons/amxmodx/configs/CodeStrikePlugins/`. There is no database to create and no table to import — SQLite handles all of it on its own.
---
## Configuration
Everything is driven by two files, without touching a single line of code:
**`codestrike_bans.ini`** — 110 settings across 14 sections: access and flags, database, join checks, history, Discord, logs, menu, HUD, sounds, chat messages, the reason list and the duration list.
**`codestrike_bans_info.ini`** — everything the banned player sees: the console text, the text in the kick window, and the instructions on how to appeal.
The texts support placeholders that are filled in automatically:
```
%name% %steamid% %ip% %reason% %admin% %length%
%expire% %timeleft% %banid% %date% %server% %bancount% %banname%
```
Any change is applied with `amx_bans_reload`, without changing the map.
---
## At a glance
| | |
|---|---|
| Version | 1.0 |
| Author | illusion @ CodeStrike |
| Database | SQLite or MySQL |
| Settings | 110 options across 2 ini files |
| Code | 5450+ lines, compiles without a single warning |
| Language | Every visible string lives in the ini files and can be translated |
---
*Every piece of text the plugin displays is edited from the configuration. You never need to touch the code to translate it or tailor it to your server.*