Installation
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
- Download from CFX Portal
- Extract to your
resourcesfolder asml_trap - Add to
server.cfg:
1ensure oxmysql
2ensure ox_lib
3ensure ml_bridge
4ensure ml_trapml_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.
_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 trapcage_trap_small: Small cage trapcage_trap_large: Large cage trapmeat_bait: Lures carnivores and omnivoresvegetable_bait: Lures herbivoreswhite_meat_bait: Lures scavengers and small predatorsrope: Repair materialwood: Repair materialmetal_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.
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.InteractionMethodmatches 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.enabledisfalse, or oxmysql is not running. - Animals ignore the bait: The bait
animalslist does not include the species spawning near the trap, or the bait expired.