twinded_lgw_instances
An instance (routing bucket) management script for RedM. Automatically switches players to separate OneSync routing buckets when they enter defined polygon zones, keeping their mount, led horse, and vehicle in sync.
Dependencies
| Resource | Required | Notes |
|---|---|---|
| twinded_libs | Yes | Free shared library |
| PolyZone | Yes | Polygon zone detection |
Compatibility
Cross-framework — works with VORP, RSG, QBCore RedM, QRCore, RedEM:RP, RPX, TPZ-CORE, and FRP. Framework is auto-detected by twinded_libs.
Installation
bash
ensure twinded_libs
ensure PolyZone
ensure twinded_lgw_instancesConfig Files
| File | Description |
|---|---|
settings.lua | Debug mode, notifications, admin groups, webhook, instance zones |
lang.lua | Translation strings |
webhook.lua | Custom webhook handler (when Config.Webhook.type = 'custom') |
See the Configuration guide for how to override these files.
Configuration Reference
settings.lua
| Option | Type | Default | Description |
|---|---|---|---|
Config.Debug | boolean | false | Enable debug logging and debug commands |
Config.Notify | boolean | true | Show notifications when entering/exiting instances |
Config.AdminCommand | string | "instance" | Admin command name |
Config.AdminGroups | table | {"admin", "dev", "superadmin"} | Groups allowed to use admin commands |
Config.Webhook.type | string | "discord" | 'discord' or 'custom' |
Config.Webhook.url | string | "" | Discord webhook URL |
Zone Fields
Each entry in Config.Zones:
| Field | Type | Description |
|---|---|---|
bucketId | number | Routing bucket ID (must be > 0, 0 = main world) |
name | string | Zone display name |
points | table | Array of vector2 points defining the polygon |
minZ | number | Minimum Z height of the zone |
maxZ | number | Maximum Z height of the zone |
webhook.lua — Embed Colors
| Color | Code | Meaning |
|---|---|---|
| Blue | 3447003 | Player entered/exited zone |
| Orange | 16744448 | Admin forced a player to a bucket |
| Red | 15158332 | Admin reset a player |
Features
- Polygon-based instances — Define zones with PolyZone polygons — auto-switch on enter/exit
- Entity sync — Mounted horse, led horse, and vehicle follow the player
- Zone stacking — Nested zones handled via a stack — exiting returns to the previous bucket
- Admin commands — Full management of player instances
- Webhook logging — Discord or custom handler
- Exports API — Client and server exports for integration
Admin Commands
| Command | Description |
|---|---|
/instance list | List all players currently in an instance |
/instance info <serverId> | Show a player's current bucket |
/instance set <serverId> <bucketId> | Force a player into a specific bucket |
/instance reset <serverId> | Reset a player to the main world |
Exports
Client
lua
-- Get current routing bucket (0 = main world)
local bucket = exports['twinded_lgw_instances']:getCurrentBucket()
-- Check if player is in a specific bucket
local inZone = exports['twinded_lgw_instances']:isInZone(bucketId)
-- Programmatically request a bucket switch
local ok = exports['twinded_lgw_instances']:requestBucketChange(bucketId)Server
lua
-- Get a player's current bucket
local bucket = exports['twinded_lgw_instances']:getPlayerBucket(serverId)
-- Set a player's bucket (with entity migration)
exports['twinded_lgw_instances']:setPlayerBucket(serverId, bucketId, entities)
-- Reset a player to the main world
exports['twinded_lgw_instances']:resetPlayerBucket(serverId)
-- Get all tracked player buckets
local all = exports['twinded_lgw_instances']:getAllPlayerBuckets()
-- Check if a player is in the main world
local main = exports['twinded_lgw_instances']:isInMainWorld(serverId)Troubleshooting
| Problem | Solution |
|---|---|
| Script doesn't start | Make sure twinded_libs and PolyZone are started before |
| Players not switching buckets | Check zone polygon points and minZ/maxZ values |
| Entities not following | Only entities owned by the player are migrated |
| Admin commands not working | Verify your character group matches Config.AdminGroups |

