Jump to content

Recommended Posts

Posted

AFK Bomb Transfer - Complete Documentation

πŸ“‹ General Information

Plugin: AFK Bomb Transfer (Optimized)
Version: 0.5
Author: steams.ro
Platform: AMX Mod X
Required Module: fakemeta


🎯 Description

The plugin automatically transfers the bomb from inactive (AFK) terrorist players to the closest active teammate. This prevents situations where the bomb remains stuck with an AFK player, affecting the gaming experience.


✨ Features

Main Functionality

  • βœ… Automatic detection of AFK players carrying the bomb
  • βœ… Automatic transfer to the closest active teammate
  • βœ… Complete movement verification (X, Y, Z - including jumps)
  • βœ… Informative HUD messages for team and new carrier
  • βœ… Optimized task system (runs only when needed)
  • βœ… C4 entity caching (improved performance)

v0.5 Optimizations

  • πŸš€ Task runs only when someone has the bomb
  • πŸš€ Position checking on all 3 axes (X, Y, Z)
  • πŸš€ Eliminated duplicate get_players() calls
  • πŸš€ Cached C4 entity for fast lookup
  • πŸš€ Checks moved outside loops for efficiency
  • πŸš€ Restructured and detailed commented code

Limitations

The plugin does NOT work in the following situations:

  • ❌ During freezetime (at round start)
  • ❌ When bomb is being planted
  • ❌ On maps without bomb sites (optional, see configuration)

βš™οΈ Installation

Requirements

  1. AMX Mod X installed on server
  2. fakemeta module enabled in modules.ini

Installation Steps

  1. Compile afkbombtransfer.sma with AMX Mod X compiler
  2. Copy afkbombtransfer.amxx to addons/amxmodx/plugins/ folder
  3. Add afkbombtransfer.amxx to addons/amxmodx/configs/plugins.ini
  4. Restart server or change map

πŸŽ›οΈ CVAR Configuration

afk_bombtransfer_spawn

afk_bombtransfer_spawn "7"

Description: Maximum allowed AFK time (in seconds) for a player who received the bomb at spawn and never moved.

Values:

  • 0 or less = Plugin disabled for this check
  • 1-60 = Recommended seconds
  • Default: 7 seconds

Example: If a player receives the bomb at spawn and remains AFK for 7 seconds without moving at all, the bomb will be transferred.


afk_bombtransfer_time

afk_bombtransfer_time "15"

Description: Maximum allowed AFK time (in seconds) for any bomb carrier who moved at least once.

Values:

  • 0 or less = Plugin disabled for this check
  • 1-120 = Recommended seconds
  • Default: 15 seconds

Example: If a player carrying the bomb stops and remains AFK for 15 seconds, the bomb will be transferred.


πŸ’¬ HUD Messages

For Terrorist Team (Green)

Bomb transferred to "NewPlayerName"
since "AFKPlayerName" is AFK
  • Color: Green (RGB: 0, 255, 0)
  • Position: Center-left (x: 0.35, y: 0.8)
  • Duration: 7 seconds

For New Carrier (Yellow)

You got the bomb!
  • Color: Yellow (RGB: 255, 255, 0)
  • Position: Center-top (x: 0.42, y: 0.3)
  • Duration: 7 seconds
  • Channel: 3

πŸ”§ Advanced Configuration

Disabling Map Check

If you want the plugin to run on ALL maps (including those without bomb sites):

In source code, comment out the line:

#define BOMB_MAP_CHECK

Becomes:

//#define BOMB_MAP_CHECK

Then recompile the plugin.


Changing Message Display Time

In source code, modify the value:

#define MSG_TIME 7.0

Example for 5 seconds:

#define MSG_TIME 5.0

πŸ” How It Works

1. AFK Detection

The plugin checks every second the position (X, Y, Z) of each terrorist:

  • If position changed β†’ timer reset to 0
  • If position is the same β†’ timer incremented

Note: Also checks Z-axis, so jumps and falls reset the timer.

2. Carrier Verification

When a player has the bomb:

  • Plugin starts the check task
  • Monitors specific AFK time (spawn vs normal)
  • Checks if player is planting the bomb

3. Bomb Transfer

When timer exceeds the set limit:

  1. Finds all active (non-AFK) terrorists
  2. Calculates distance from AFK carrier
  3. Selects the closest active player
  4. Forces bomb drop from AFK player
  5. Transfers backpack to new carrier
  6. Displays HUD messages

4. Active Optimizations

  • Task stops automatically when:
    • No bomb carrier exists
    • Less than 2 terrorists
    • It's freezetime
    • Plugin disabled via CVAR

πŸ“Š Usage Examples

Example 1: Competitive Server

// Tight timings for fast action
afk_bombtransfer_spawn "5"
afk_bombtransfer_time "10"

Example 2: Public/Casual Server

// More relaxed timings
afk_bombtransfer_spawn "10"
afk_bombtransfer_time "20"

Example 3: Fun/Zombie Server

// Plugin disabled
afk_bombtransfer_spawn "0"
afk_bombtransfer_time "0"

πŸ› Troubleshooting

Plugin Not Working

Check:

  1. βœ… fakemeta module is enabled in modules.ini
  2. βœ… Plugin is in plugins.ini
  3. βœ… CVARs are not set to 0 or negative values
  4. βœ… Map has bomb sites (if BOMB_MAP_CHECK is active)

Bomb Not Transferring

Possible causes:

  • All terrorists are AFK
  • It's freezetime
  • Bomb is being planted
  • Less than 2 terrorists on server

Messages Not Appearing

Check:

  • hud_centerid in game (must not be 0)
  • HUD settings in game

πŸ“ Changelog

v0.5 (2025) - steams.ro

  • ✨ Added Z-axis checking (jumps/falls)
  • πŸš€ Optimized task (runs only when needed)
  • πŸš€ Eliminated duplicate get_players() calls
  • πŸš€ C4 entity caching
  • πŸš€ Checks moved outside loops
  • πŸ“ Extended documentation and improved comments
  • πŸ”§ Separate function for transfer
  • 🎯 Separate event for bomb planting

v0.4

  • Improved backpack transfer method
  • Support for pcvar natives
  • Code optimizations

v0.3

  • Fakemeta instead of engine
  • Option to disable map checking
  • Improved backpack finding method

v0.2

  • Format fixes
  • Code optimizations
  • Improved description

v0.1

  • First release

πŸ“ž Support

For issues, bugs, or suggestions:

  • Website: steams.ro
  • Forum: AMX Mod X section

πŸ“œ License

This plugin is provided "as is" without warranties.


πŸ™ Credits

Original Author: Wr0n (www.mortall.ro)
v0.5 Optimizations: steams.ro


Documentation generated for version 0.5

afkbombtransfer.sma afkbombtransfer.amxx

×
×
  • Create New...