GitHunt
SA

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 F9 to 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 +right and +left console 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 compiles advanced.py into a standalone .exe and 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

  1. Install Dependencies
    Open a terminal in the project directory and install the required packages:
pip install -r requirements.txt
  1. Find Your Reconnect Coordinates
    Run find_cords.py. Hover your mouse over where the "Reconnect" button appears in the CS2 main menu to get the X and Y coordinates. Update RECONNECT_X and RECONNECT_Y in advanced.py if they differ from the defaults (960, 540).
  2. Set Up the Telegram Bot
  • Message @BotFather on Telegram to create a new bot and get your BOT_TOKEN.
  • Run advanced_get_chat_id.py and message your bot to find your personal CHAT_ID.
  1. Create the Environment File
    Create a file named exactly .env in 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.

  1. Ensure your .env file is in the same folder as advanced.exe.
  2. Double-click advanced.exe. It will automatically prompt for Administrator privileges.
  3. Keep the application running in the background while you play.

How It Works in Game

  1. Hear an alert. Press F9 and run to safety. The script instantly disconnects you.
  2. The script messages your allowed Telegram chats asking if technical time was used and if you want to add extra seconds.
  3. Answer the prompts from your phone.
  4. The timer starts. You will receive updates in Telegram.
  5. Once the timer finishes (or if you type "reconnect"), the script clicks the CS2 Reconnect button.
  6. The script enters an Anti-AFK loop.
  7. 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.

SamuraiPolix/CS2-Red-Alert-Script | GitHunt