Skip to content

twinded_libs

Free shared utility library for all Twinded scripts. Provides a lightweight module system (tw global) and common exports used across scripts.

Free Resource

twinded_libs is free and required by all Twinded scripts. Download it from the Tebex store.

Installation

Place twinded_libs in your resources folder and ensure it before any Twinded script:

bash
ensure twinded_libs

Module System

Scripts include the library via their fxmanifest.lua:

lua
shared_scripts {
    '@twinded_libs/init.lua',
}

This creates a global tw object with lazy-loaded modules.

Available Modules

ModuleSideDescription
tw.fwsharedCross-framework abstraction (VORP, RSG, QBCore, etc.)
tw.callbacksharedBidirectional client-server callbacks
tw.hooksharedAction/filter hook system (WordPress-style)
tw.emitsharedOptimized event emission with bandwidth control
tw.blipclientMap blips with auto-cleanup on resource stop
tw.promptclientNative RedM interaction prompts (hold-to-complete)
tw.entitysharedEntity creation, deletion, fade in/out
tw.notifsharedNative RedM notifications (right, left, top)
tw.timeoutsharedTimeouts, loops, delays
tw.progressbarclientNUI progress bar with themes (linear, circle, innercircle)
tw.menuclientNUI interactive menu (cross-framework)
tw.tablesharedExtended table functions (copy, merge, upsert, etc.)
tw.databaseserverMySQL table/column management via oxmysql
tw.webhookserverDiscord webhook logging
tw.witnessserverWitness alerts — broadcast to players by job + temporary blip
tw.screenclientScreen fade in/out utilities
tw.lightclientDynamic light sources with easing transitions
tw.uiclientNative UI elements (rank bar, countdown timer)
tw.playerclientAuto-updated player info (ped, coords, serverId)
tw.cameraclientInteractive freecam system
tw.gameEventsclientNative RedM game event listener
DataViewclientBinary buffer manipulation
tw.i18nsharedInternationalization with locale management
tw.pedTextureclientPed texture overlays (makeup, scars, hair)
tw.rawKeysclientRaw keyboard input (QWERTY/AZERTY)
tw.utilssharedUtility functions (fallback, screen_to_world, asset loading)
tw.filesharedFile loading with dot notation paths
tw.text3dclientFloating 3D text above world coordinates
tw.inputclientNative RedM input system
tw.animationclientAnimation playback and management
tw.datesharedTimestamps and duration formatting
tw.promisesharedSync wrappers for callback-based functions
tw.waitersharedWait-until-condition with timeout
tw.debuggersharedBenchmarking and visual debugging
Print utilitiessharedColored console output and debug logging
Math extensionssharedlerp, round, clamp, hex conversion
String extensionssharedsplit, trim, version compare, number formatting

Usage Examples

lua
-- Ready callback (wait for lib initialization)
tw.ready(function()
    -- your initialization code
end)

-- Cleanup on resource stop
tw.stopped(function()
    -- cleanup code
end)

Blips

lua
tw.blip.create(vec3(x, y, z), "Label", "blip_sprite")

Prompts

lua
tw.prompt.create(group, "Label", 'INPUT_INTERACT_OPTION1', false)
tw.prompt.displayGroup(group, "Title")  -- call each frame
if tw.prompt.isCompleted(group, 'INPUT_INTERACT_OPTION1') then
    -- handle interaction
end

Entities

lua
local entity = tw.entity.create("model_name", coords, heading, networked)
tw.entity.delete(entity)

Notifications

lua
tw.notif.rightSuccess("You found 3x Apple")
tw.notif.rightError("Not enough space")
tw.notif.right(text, dict, icon, color, duration)
tw.notif.left(title, text, dict, icon, color, duration)
tw.notif.simpleTop(title, subtitle, duration)

Exports

Shared

HasJobAccess(jobs, current_job) → boolean

Check if a job is in the allowed list. Returns true if jobs is nil or empty.

lua
local allowed = exports['twinded_libs']:HasJobAccess({"doctor", "sheriff"}, player_job)

Client

AttachProp(prop_name, offset, bone) → entity | nil

Attach a prop model to the player's bone with offset.

lua
local prop = exports['twinded_libs']:AttachProp(
    "p_axe02x",
    { x = 0, y = 0, z = 0.5, rx = 0, ry = 0, rz = 0 },
    "SKEL_R_Finger12"
)

DeleteProp(prop)

Safely detach and delete a prop entity.

lua
exports['twinded_libs']:DeleteProp(prop)

Server

SendWebhook(url, data)

Send a message to a Discord webhook. Restricted to twinded_* resources only.

lua
exports['twinded_libs']:SendWebhook(Config.Webhook.url, {
    username = "My Script",
    embeds = {{
        title = "Event",
        description = "Details",
        color = 3066993,
    }},
})

IsRateLimited(key, min_time) → boolean

Per-key rate limiting. Returns true if the action should be blocked.

lua
if exports['twinded_libs']:IsRateLimited(source, 3) then return end

ClearRateLimit(key) / ClearRateLimitsByPrefix(prefix)

Cleanup rate limit entries (call in playerDropped).

lua
exports['twinded_libs']:ClearRateLimit(source)

Premium RedM Scripts — Multi-Framework