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.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.tablesharedExtended table functions (copy, merge, upsert, etc.)
tw.dataviewclientBinary buffer manipulation
tw.witnessserverWitness alerts — broadcast to players by job + temporary blip
tw.text3dclientFloating 3D text above world coordinates
tw.inputclientNative RedM input system
tw.animationclientAnimation playback and management
tw.printsharedColored console output and debug logging

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 for VORP Framework