Installation

3 min readUpdated Today

Overview

ML Trap adds placeable snap traps and cage traps that lure, hold and kill wild animals, with optional player capture. Traps persist through restarts in the database. The interaction panel and the floating in-world tag are rendered in the game.

Quick Start

  1. Download from CFX Portal
  2. Extract to your resources folder as ml_trap
  3. Add to server.cfg:
server.cfg
1ensure oxmysql
2ensure ox_lib
3ensure ml_bridge
4ensure ml_trap
Load Order

ml_trap must start AFTER ml_bridge.

Stream Assets

The trap, cage and bait models ship in the resource stream/ folder and load automatically. No manual import is required.

Database

The persistence table is created automatically on first start:

ml_traps: Stores persistent traps: type, owner, position, state, bait, capture and durability

Traps are persistent by default and saved to this table. Set persistent to false on a trap type to keep it in memory only.

Manual Provisioning

_INSTALL/schema.sql contains the same table if you prefer to create it by hand or disable automatic schema init.

Item Registration

Register the following items in your inventory. The defaults live in _INSTALL/items.lua, ready to copy.

  • snap_trap: Walk-on ground trap
  • cage_trap_small: Small cage trap
  • cage_trap_large: Large cage trap
  • meat_bait: Lures carnivores and omnivores
  • vegetable_bait: Lures herbivores
  • white_meat_bait: Lures scavengers and small predators
  • rope: Repair material
  • wood: Repair material
  • metal_scrap: Repair material

Item names are configurable in Config.TrapTypes. Any rename here must match the inventory item and, for existing servers, the trap_type and bait_type values stored in ml_traps.

Item Images

Ready-made icons ship in _INSTALL/images, named to match the item keys. Copy them into your inventory image folder (for ox_inventory that is ox_inventory/web/images). The panel falls back to a generic icon when an image is missing.

Verify

Place a snap trap item from the inventory, then place it in the world. The trap prop appears with its interaction option, and a floating tag shows above it.

To confirm persistence, place a cage trap and check that a row appears in ml_traps.

  • No interaction on the trap: Confirm Config.InteractionMethod matches an available target system, or switch to 'textui'.
  • Trap items do nothing when used: The item name in the inventory does not match a key in Config.TrapTypes.
  • Cage traps disappear on restart: Config.Persistence.enabled is false, or oxmysql is not running.
  • Animals ignore the bait: The bait animals list does not include the species spawning near the trap, or the bait expired.