Skip to content

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

ResourceRequiredNotes
twinded_libsYesFree shared library
PolyZoneYesPolygon 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_instances

Config Files

FileDescription
settings.luaDebug mode, notifications, admin groups, webhook, instance zones
lang.luaTranslation strings
webhook.luaCustom webhook handler (when Config.Webhook.type = 'custom')

See the Configuration guide for how to override these files.

Configuration Reference

settings.lua

OptionTypeDefaultDescription
Config.DebugbooleanfalseEnable debug logging and debug commands
Config.NotifybooleantrueShow notifications when entering/exiting instances
Config.AdminCommandstring"instance"Admin command name
Config.AdminGroupstable{"admin", "dev", "superadmin"}Groups allowed to use admin commands
Config.Webhook.typestring"discord"'discord' or 'custom'
Config.Webhook.urlstring""Discord webhook URL

Zone Fields

Each entry in Config.Zones:

FieldTypeDescription
bucketIdnumberRouting bucket ID (must be > 0, 0 = main world)
namestringZone display name
pointstableArray of vector2 points defining the polygon
minZnumberMinimum Z height of the zone
maxZnumberMaximum Z height of the zone

webhook.lua — Embed Colors

ColorCodeMeaning
Blue3447003Player entered/exited zone
Orange16744448Admin forced a player to a bucket
Red15158332Admin 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

CommandDescription
/instance listList 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

ProblemSolution
Script doesn't startMake sure twinded_libs and PolyZone are started before
Players not switching bucketsCheck zone polygon points and minZ/maxZ values
Entities not followingOnly entities owned by the player are migrated
Admin commands not workingVerify your character group matches Config.AdminGroups

Premium RedM Scripts — Multi-Framework