SamuraiPolix/CS2-Red-Alert-Script
A Python utility for CS2 that provides an instant disconnect hotkey for emergency rocket sirens (Tzeva Adom). Includes a Telegram bot to remotely manage the timeout, auto-reconnect, and prevent AFK kicks while in the shelter.
Counter-Strike 2 | Red Alert Script
๐ Remote Disconnect, Reconnect, and Anti-AFK
See disclaimer at the bottom!
A Python utility for Counter-Strike 2 that provides an instant, one-key disconnect hotkey (F9). Designed for emergency situations (like a siren/Tzeva Adom) where you need to immediately abandon the PC and head to a shelter (Mamad).
The advanced version integrates with a Telegram bot, allowing you to manage technical timeouts, execute a remote reconnect, and trigger an anti-AFK loop right from your phone while waiting in the shelter. It supports multiple authorized Chat IDs, so a spouse or family member can also control the script from their device.
If, for example, you have a friend in the same match that didn't get an alert and managed to take multiple tactical timeouts, he will be able to control when you reconnect.
Features
- Instant Disconnect: Press
F9to immediately open the CS2 console, disconnect from the server, and drop to the main menu. - Telegram Integration: Answer timeout questions (technical time used, extra seconds needed) remotely via a Telegram Bot.
- Auto-Reconnect: Automatically clicks the CS2 "Reconnect" button at the exact right time, or immediately if a 2-minute timeout passes without a response.
- Anti-AFK Loop: Prevents server kicks by automating
+rightand+leftconsole commands after reconnecting. - Remote Override: Send "here" to pause the timer or "reconnect" to force an immediate rejoin.
- Whitelist Security: Only authorized Telegram Chat IDs can trigger commands.
Repository Structure
simple.py: The basic, offline version of the script with terminal prompts.advanced.py: The main script featuring the Telegram Bot integration, timeout logic, and anti-AFK loop.advanced_get_chat_id.py: A helper script to quickly find your Telegram Chat ID for authorization.find_cords.py: A helper script to print your mouse's X and Y coordinates (used to locate the CS2 Reconnect button).build.bat: A Windows batch script that compilesadvanced.pyinto a standalone.exeand cleans up temporary build folders.requirements.txt: Python dependencies required to run the scripts..env(Not included in repo, a template is included): Your local configuration file containing secrets.
Prerequisites & Setup
- Install Dependencies
Open a terminal in the project directory and install the required packages:
pip install -r requirements.txt
- Find Your Reconnect Coordinates
Runfind_cords.py. Hover your mouse over where the "Reconnect" button appears in the CS2 main menu to get the X and Y coordinates. UpdateRECONNECT_XandRECONNECT_Yinadvanced.pyif they differ from the defaults (960, 540). - Set Up the Telegram Bot
- Message
@BotFatheron Telegram to create a new bot and get yourBOT_TOKEN. - Run
advanced_get_chat_id.pyand message your bot to find your personalCHAT_ID.
- Create the Environment File
Create a file named exactly.envin the root directory and add your credentials. You can add multiple Chat IDs separated by commas.
BOT_TOKEN=your_bot_token_here
ALLOWED_CHAT_IDS=123456789,987654321
Usage
Running the Script
You can run the script directly via Python:
python advanced.py
Note: Because the script listens for global hotkeys, you must run your terminal or IDE as an Administrator.
Building the Executable
To run the script without a terminal, double-click build.bat.
This uses PyInstaller to compile advanced.py into advanced.exe and moves it to the root directory.
- Ensure your
.envfile is in the same folder asadvanced.exe. - Double-click
advanced.exe. It will automatically prompt for Administrator privileges. - Keep the application running in the background while you play.
How It Works in Game
- Hear an alert. Press F9 and run to safety. The script instantly disconnects you.
- The script messages your allowed Telegram chats asking if technical time was used and if you want to add extra seconds.
- Answer the prompts from your phone.
- The timer starts. You will receive updates in Telegram.
- Once the timer finishes (or if you type "reconnect"), the script clicks the CS2 Reconnect button.
- The script enters an Anti-AFK loop.
- When you return to your PC, hold F10 or send "back" on Telegram to stop the Anti-AFK loop and resume playing.
Disclaimer / Anti-Cheat Warning
Using hardware simulation libraries (pyautogui, keyboard) is generally safe for VAC but can be flagged by intrusive, kernel-level anti-cheats. If you play on third-party platforms like FACEIT, their anti-cheat may block the global keyboard hooks or flag the automated input.
In any case - Use the scripts at your own risk. You are the only one responsible for the affects of using this.