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:
ensure twinded_libsModule System
Scripts include the library via their fxmanifest.lua:
shared_scripts {
'@twinded_libs/init.lua',
}This creates a global tw object with lazy-loaded modules.
Available Modules
| Module | Side | Description |
|---|---|---|
tw.fw | shared | Cross-framework abstraction (VORP, RSG, QBCore, etc.) |
tw.callback | shared | Bidirectional client-server callbacks |
tw.hook | shared | Action/filter hook system (WordPress-style) |
tw.emit | shared | Optimized event emission with bandwidth control |
tw.blip | client | Map blips with auto-cleanup on resource stop |
tw.prompt | client | Native RedM interaction prompts (hold-to-complete) |
tw.entity | shared | Entity creation, deletion, fade in/out |
tw.notif | shared | Native RedM notifications (right, left, top) |
tw.timeout | shared | Timeouts, loops, delays |
tw.progressbar | client | NUI progress bar with themes (linear, circle, innercircle) |
tw.menu | client | NUI interactive menu (cross-framework) |
tw.table | shared | Extended table functions (copy, merge, upsert, etc.) |
tw.database | server | MySQL table/column management via oxmysql |
tw.webhook | server | Discord webhook logging |
tw.witness | server | Witness alerts — broadcast to players by job + temporary blip |
tw.screen | client | Screen fade in/out utilities |
tw.light | client | Dynamic light sources with easing transitions |
tw.ui | client | Native UI elements (rank bar, countdown timer) |
tw.player | client | Auto-updated player info (ped, coords, serverId) |
tw.camera | client | Interactive freecam system |
tw.gameEvents | client | Native RedM game event listener |
DataView | client | Binary buffer manipulation |
tw.i18n | shared | Internationalization with locale management |
tw.pedTexture | client | Ped texture overlays (makeup, scars, hair) |
tw.rawKeys | client | Raw keyboard input (QWERTY/AZERTY) |
tw.utils | shared | Utility functions (fallback, screen_to_world, asset loading) |
tw.file | shared | File loading with dot notation paths |
tw.text3d | client | Floating 3D text above world coordinates |
tw.input | client | Native RedM input system |
tw.animation | client | Animation playback and management |
tw.date | shared | Timestamps and duration formatting |
tw.promise | shared | Sync wrappers for callback-based functions |
tw.waiter | shared | Wait-until-condition with timeout |
tw.debugger | shared | Benchmarking and visual debugging |
| Print utilities | shared | Colored console output and debug logging |
| Math extensions | shared | lerp, round, clamp, hex conversion |
| String extensions | shared | split, trim, version compare, number formatting |
Usage Examples
-- Ready callback (wait for lib initialization)
tw.ready(function()
-- your initialization code
end)
-- Cleanup on resource stop
tw.stopped(function()
-- cleanup code
end)Blips
tw.blip.create(vec3(x, y, z), "Label", "blip_sprite")Prompts
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
endEntities
local entity = tw.entity.create("model_name", coords, heading, networked)
tw.entity.delete(entity)Notifications
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.
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.
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.
exports['twinded_libs']:DeleteProp(prop)Server
SendWebhook(url, data)
Send a message to a Discord webhook. Restricted to twinded_* resources only.
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.
if exports['twinded_libs']:IsRateLimited(source, 3) then return endClearRateLimit(key) / ClearRateLimitsByPrefix(prefix)
Cleanup rate limit entries (call in playerDropped).
exports['twinded_libs']:ClearRateLimit(source)
