CodeRanch - UI System
Lightweight and modern UI helpers for RedM resources: show in-game toast notifications and run a cancellable progress bar with optional animations and props.
Features
Simple, fast, modern notifications (success, info, warning, error)
Configurable progress bar with text and timeout
ESC cancel support (key configurable in
config.lua)Optional animation and prop handling while progress is active
Built-in NUI preview/editor command (
/ui)
Requirements
RedM (cerulean)
Installation
Exports
From fxmanifest.lua:
Notification:
exports['coderanch-ui']:SendNotification(type, message, timeout)
Progress Bar:
exports['coderanch-ui']:startProgress(action, onProcessStart, onProcessTick, onProcessComplete, onProcessCancel)
Additionally, there is an event for notifications:
TriggerEvent('coderanch-ui:createNotification', type, message, timeout)
Usage β Notifications
Signature:
Parameters:
type: one of"success" | "info" | "warning" | "error"(default:"info")message: string (default:"No message provided")timeout: number in ms (default:5000)
Examples:
Usage β Progress Bar
Signature:
Action table fields:
text(string): Text displayed on the bartimeout(number): Duration in msuseWhileDead(boolean): Allow when player is deadcancelable(boolean): Allow cancel with ESCdisablemovement(boolean): Intended movement restriction (client-only flag)disablecombat(boolean): Intended combat restriction (client-only flag)setunarmed(boolean): Intended to set unarmed (client-only flag)animation(table):animDict(string)anim(string)flags(number)task(string) β alternative scenario task
prop(table):model(string): model name/hashbone(number|string): bone index or name (default:SKEL_R_HAND)coords(vec3): attachment offsetrotation(vec3): attachment rotation
Callbacks (all optional):
onProcessStart()β called once at the beginningonProcessTick()β called every frame while runningonProcessComplete()β called when finished without cancelonProcessCancel()β called if canceled (ESC or invalid state)
Cancel key:
Defined in
config.luaβConfig.escapeKey(default: ESC)
Callback Functions β Named Usage
You can define named functions and pass them into startProgress for clarity and reuse:
Notes:
onProcessTickis called very frequently; avoid heavy logic inside.prop.boneaccepts a bone name or index; defaults toSKEL_R_HANDif omitted.If progress is canceled (ESC or player death without
useWhileDead),onProcessCancelruns andonProcessCompletewill not.
NUI Preview/Editor
Command:
/uiOpens a simple UI to preview notifications and progress bar.
Close using the UIβs close button.
Configuration
Edit config.lua:
Key hash reference is included in config.lua comments for convenience.
License
This resource is developed by CodeRanch. Commercial usage requires permission.