When players disconnect, they don't vanish โ they sleep. Proximity-loaded sleeping peds, full skin sync from playerskins, robbery & carry mechanics, GlobalState sync, ox_target interaction.
Built on ox_core ยท ox_lib ยท ox_inventory ยท ox_target ยท oxmysql
Built by Red Dragon Elite | SerpentsByte
- Overview
- Features
- Dependencies
- Installation
- Configuration
- How It Works
- Admin System
- Developer API
- Database
- Performance
- Troubleshooting
- Changelog
- License
RDE SleepMod is a production-grade sleep and logout system for FiveM servers running ox_core. When a player disconnects or logs out, a sleeping ped is created at their last position โ with their exact appearance loaded from the playerskins table. Other players can rob them, carry them, or admins can force-wake them. Everything is proximity-loaded and GlobalState-synced for maximum performance.
| Feature | Generic Sleep Scripts | RDE SleepMod |
|---|---|---|
| Skin preservation | โ Default ped | โ Full playerskins sync |
| Proximity loading | โ Always loaded | โ Client-side LOD |
| Robbery system | โ | โ ox_inventory stash |
| Carry mechanics | โ | โ Full carry & release |
| Real-time sync | Network events | โ GlobalState โ instant |
| Admin wake | โ | โ Triple-verified |
| Ground placement | โ Floating peds | โ GetGroundZ + PlaceOnGround |
| Multi-language | โ | โ EN + DE built-in |
| Server restart safe | โ Lost on restart | โ MySQL persistent |
| Performance | Heavy | โ < 0.01ms idle |
- Sleeping Peds on Logout โ Players leave behind their character when they disconnect or use
/sleeplogout - Full Skin Sync โ Appearance loaded directly from ox_core
playerskinstable (components, props, headBlend, faceFeatures, headOverlays, hair, tattoos, eyeColor) - Robbery System โ Search pockets via progress bar, opens ox_inventory stash with the sleeping player's items
- Carry Mechanics โ Pick up sleeping peds, carry them with fireman's carry animation, release with [E]
- Admin Wake โ Triple-verified admin system (ACE + ox_core Groups + Steam ID) to force-wake sleeping players
- Sleeping Animation โ Proper GTA V lying animation (
amb@world_human_bum_slumped) - Auto-Remove on Reconnect โ When a player logs back in, their sleeping ped is automatically removed
- Proximity Loading โ Client-side ped spawning with configurable render/despawn distance and hysteresis (rde_props pattern)
- GlobalState Sync โ Server broadcasts sleeping player positions via
GlobalState.sleepingPlayers, clients react in real-time - Client-Side Peds โ Zero server entity overhead, no CNetObj limits, no network entity spawning
- Ground Placement โ
GetGroundZFor_3dCoord+PlaceObjectOnGroundProperlyfor perfect placement on all terrain - Auto-Save Cache โ Player appearance and inventory cached to MySQL every 5 minutes for crash protection
- Skin Backfill โ On server start, any sleeping entries with missing skin data are automatically loaded from playerskins
- Multi-Language โ English + German built-in, easily expandable
- ox_target Interaction โ Clean target options with Font Awesome icons
- Progress Bars โ Smooth animations for robbery
- Smart Notifications โ Contextual feedback via ox_lib
- Debug Mode โ Verbose console logging with
/sleeptestcommand
| Resource | Required | Notes |
|---|---|---|
| oxmysql | โ Required | Database layer |
| ox_core | โ Required | Player/character framework |
| ox_lib | โ Required | UI, callbacks, notifications |
| ox_inventory | โ Required | Stash system for robbery |
| ox_target | โ Required | Ped interaction |
Optional: | illenium-appearance | Optional | If installed, used for skin application (fallback: manual component application) |
cd resources
git clone https://github.com/RedDragonElite/rde_sleep.git rde_sleepmodensure oxmysql
ensure ox_core
ensure ox_lib
ensure ox_inventory
ensure ox_target
ensure rde_sleepmod
# Optional: Admin ACE permissions
add_ace group.admin rde.sleepmod allow
add_ace group.superadmin rde.sleepmod allowOrder matters.
rde_sleepmodmust start after all its dependencies.
The rde_sleepmod table is created automatically on first start. No manual SQL import needed.
Edit config.lua to adjust language, proximity distances, animation, admin permissions, and UI.
restart rde_sleepmod
Test with /sleeplogout in-game.
Config.DefaultLanguage = 'en' -- 'en' or 'de'
Config.Debug = false -- verbose console outputConfig.Performance = {
renderDistance = 200.0, -- spawn sleeping peds within this range
despawnDistance = 250.0, -- despawn beyond this (hysteresis)
proximityTick = 1000, -- check interval in ms
maxVisiblePeds = 50, -- max rendered sleeping peds
skinApplyDelay = 200, -- ms delay before skin application
animApplyDelay = 100, -- ms delay before animation
}Config.RobDuration = 3500 -- robbery progress bar duration (ms)
Config.RobDistance = 2.5 -- max interaction range
Config.CarryDistance = 2.5 -- max carry pickup range
Config.InvinciblePeds = true -- sleeping peds can't be killed
Config.MaxSlots = 50 -- stash slot count
Config.MaxWeight = 100000 -- stash max weightConfig.SleepingAnimation = {
dict = 'amb@world_human_bum_slumped@male@laying_on_left_side@base',
clip = 'base'
}Config.AdminSystem = {
acePermission = 'rde.sleepmod',
steamIds = { 'steam:110000101605859' },
oxGroups = { ['admin'] = 0, ['superadmin'] = 0, ['management'] = 0 },
checkOrder = {'ace', 'oxcore', 'steam'}
}Config.TargetIcons = {
rob = 'fas fa-magnifying-glass',
carry = 'fas fa-people-carry-box',
wake = 'fas fa-bell',
}Config.DatabaseTable = 'rde_sleepmod'
Config.AutoCreateTable = true
Config.PlayerSkinsColumn = 'citizenid' -- Column in playerskins table (some use 'charid')- Disconnect or
/sleeplogoutโ Your character stays in the world as a sleeping ped - Other players see you โ With your exact skin, clothes, tattoos, and appearance
- They can rob you โ ox_target โ Rob Player โ progress bar โ opens your inventory stash
- They can carry you โ ox_target โ Carry Player โ fireman's carry โ [E] to release
- You log back in โ Your sleeping ped is automatically removed
- Wake Players โ ox_target โ Wake Player (admin-only option, triple-verified)
- Debug โ
/sleeptestshows spawned peds and GlobalState count
โโโโโโโโโโโโโโโ GlobalState.sleepingPlayers โโโโโโโโโโโโโโโโ
โ SERVER โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ CLIENT โ
โ โ โ โ
โ โข MySQL DB โ lib.callback (skin data) โ โข Proximity โ
โ โข playerskinsโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ Loop โ
โ โข Stash mgmt โ โ โข Ped spawn โ
โ โข Admin auth โ โ โข Skin apply โ
โ โ โ โข ox_target โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
Server stores data only โ no entities, no network peds. Client handles all ped spawning via proximity loading, requesting skin data on-demand via callbacks.
Admin access uses triple verification โ checked in configurable order:
# server.cfg
add_ace group.admin rde.sleepmod allowConfig.AdminSystem.oxGroups = {
['admin'] = 0,
['superadmin'] = 0,
}Config.AdminSystem.steamIds = {
'steam:110000101605859',
}-- Get sleeping player data
local data = exports.rde_sleepmod:GetSleepingPlayer('DM1881')
-- Get all sleeping players
local all = exports.rde_sleepmod:GetAllSleepingPlayers()
-- Remove a sleeping player externally
exports.rde_sleepmod:RemoveSleepingPlayer('DM1881')-- Check if an entity is a sleeping clone
local isSleeping = exports.rde_sleepmod:IsClone(entity)
local isSleeping = exports.rde_sleepmod:IsSleepingClone(entity)-- Read sleeping player positions from any client
local sleepers = GlobalState.sleepingPlayers
-- Returns: { ['DM1881'] = { x, y, z, w, model }, ... }Table is auto-created on first start:
CREATE TABLE rde_sleepmod (
identifier VARCHAR(60) PRIMARY KEY,
charid INT DEFAULT NULL,
coords TEXT NOT NULL,
model INT NOT NULL,
skin LONGTEXT,
inventory LONGTEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);Skin data is loaded from the playerskins table using the column configured in Config.PlayerSkinsColumn (default: citizenid) and cached in rde_sleepmod.skin for persistence across server restarts.
| Aspect | Traditional Approach | RDE SleepMod |
|---|---|---|
| Entity type | Server-side network peds | Client-side local peds |
| CNetObj usage | 1 per sleeping ped | 0 |
| Sync method | Network events / polling | GlobalState (instant) |
| Rendering | All peds always loaded | Proximity-based LOD |
| Skin loading | On spawn (blocking) | On-demand callback (async) |
| Sleeping Players | Client Impact | Server Impact |
|---|---|---|
| 10 | Negligible | < 0.01ms |
| 50 | Negligible | < 0.01ms |
| 100 | < 1% FPS | < 0.02ms |
| 500 | ~2% FPS (only nearby) | < 0.05ms |
- Zero server entities โ Client creates local peds, no server overhead
- Proximity culling โ Only peds within render distance are spawned
- Hysteresis โ 50m gap between spawn/despawn distance prevents flicker
- Async skin loading โ Skin data loaded via callback, doesn't block spawn
- GlobalState โ Single statebag update replaces hundreds of network events
Skin not showing on sleeping ped?
Check Config.PlayerSkinsColumn in config.lua โ it must match the column name in your playerskins table (usually citizenid or charid). Also verify the active column exists. Enable Config.Debug = true and check console for skin: YES/NO messages.
Sleeping peds not visible after server restart?
The script loads all sleeping entries from MySQL on start and syncs via GlobalState. If peds don't appear, check that oxmysql starts before rde_sleepmod in your server.cfg.
Floating peds / peds underground?
The script uses GetGroundZFor_3dCoord + PlaceObjectOnGroundProperly. If ground detection fails (interior, custom MLO), the ped uses stored Z coordinates as fallback.
ox_target options not showing?
Ensure ox_target starts before rde_sleepmod. Check F8 console for errors. The target is set up after skin and animation are applied โ there's a ~800ms delay after spawn.
Rob Player not working?
Verify ox_inventory is running. Check server console for stash registration errors. The stash is created on-demand when a player initiates robbery.
Admin Wake not showing?
Admin status is checked once on player load. If you change admin groups, the player needs to relog. Verify ACE permissions, ox_core groups, or Steam IDs in config.lua.
| Command | Access | Description |
|---|---|---|
/sleeplogout |
Player | Create sleeping ped and logout |
/sleeptest |
Debug only | Print spawned ped and GlobalState counts |
- Fixed: Ox.GetPlayer() always returns object โ now checks player.charId (per ox_core docs)
- Fixed: player.getGroups() call syntax with proper type checking
- Fixed: GlobalState can't be set to nil โ uses empty table on resource stop
- Fixed: exports.ox_inventory calls use documented colon syntax
- Fixed: playerskins column name now configurable via Config.PlayerSkinsColumn
- Fixed: Input validation on createSleepingPed NetEvent (prevents spam)
- Fixed: Admin check runs per-target instead of once at init (race condition fix)
- Fixed: Carry-drop no longer uses GetGroundZFor_3dCoord (caused roof placement in interiors)
- Fixed: Spawn position uses exact stored Z (no compounding drift)
- Fixed: Online players cleaned from DB on script restart (3-pass cleanup)
- Fixed: Config.Debug defaults to false for production
- Fixed: Version numbers synced across all files
- Proximity-loaded sleeping peds (rde_props pattern)
- GlobalState sync โ zero network events
- Full skin sync from
playerskinstable - Client-side ped spawning โ zero server entity overhead
- Robbery system with ox_inventory stash
- Carry mechanics with fireman's carry animation
- Triple-verified admin wake system
- Ground placement with
PlaceObjectOnGroundProperly - Auto-save cache every 5 minutes
- Skin backfill on server start
- Multi-language support (EN/DE)
- Production-grade error handling
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit:
git commit -m 'Add your feature' - Push:
git push origin feature/your-feature - Open a Pull Request
Guidelines: follow existing Lua conventions, comment complex logic, test on a live server before PR, update docs if adding features.
###################################################################################
# #
# .:: RED DRAGON ELITE (RDE) - BLACK FLAG SOURCE LICENSE v6.66 ::. #
# #
# PROJECT: RDE_SLEEPMOD v1.1.0 (SLEEP & LOGOUT SYSTEM FOR FIVEM) #
# ARCHITECT: .:: RDE โง Shin [โณ แแ
แฑแแ
แพแแ แแแแ
โฝ] ::. | https://rd-elite.com #
# ORIGIN: https://github.com/RedDragonElite #
# #
# WARNING: THIS CODE IS PROTECTED BY DIGITAL VOODOO AND PURE HATRED FOR LEAKERS #
# #
# [ THE RULES OF THE GAME ] #
# #
# 1. // THE "FUCK GREED" PROTOCOL (FREE USE) #
# You are free to use, edit, and abuse this code on your server. #
# Learn from it. Break it. Fix it. That is the hacker way. #
# Cost: 0.00โฌ. If you paid for this, you got scammed by a rat. #
# #
# 2. // THE TEBEX KILL SWITCH (COMMERCIAL SUICIDE) #
# Listen closely, you parasites: #
# If I find this script on Tebex, Patreon, or in a paid "Premium Pack": #
# > I will DMCA your store into oblivion. #
# > I will publicly shame your community. #
# > I hope your server lag spikes to 9999ms every time you blink. #
# SELLING FREE WORK IS THEFT. AND I AM THE JUDGE. #
# #
# 3. // THE CREDIT OATH #
# Keep this header. If you remove my name, you admit you have no skill. #
# You can add "Edited by [YourName]", but never erase the original creator. #
# Don't be a skid. Respect the architecture. #
# #
# 4. // THE CURSE OF THE COPY-PASTE #
# This code uses GlobalState, proximity loading, and async skin callbacks. #
# If you just copy-paste without reading, it WILL break. #
# Don't come crying to my DMs. RTFM or learn to code. #
# #
# -------------------------------------------------------------------------- #
# "We build the future on the graves of paid resources." #
# "REJECT MODERN MEDIOCRITY. EMBRACE RDE SUPERIORITY." #
# -------------------------------------------------------------------------- #
###################################################################################
TL;DR:
- โ Free forever โ use it, edit it, learn from it
- โ Keep the header โ credit where it's due
- โ Don't sell it โ commercial use = instant DMCA
- โ Don't be a skid โ copy-paste without reading won't work anyway
rde_sleepmod/
โโโ fxmanifest.lua # Resource manifest
โโโ config.lua # All configuration + languages
โโโ client.lua # Proximity loading, skin, animation, carry, robbery
โโโ server.lua # Database, GlobalState sync, stash, admin
โโโ README.md # You're reading it
| ๐ GitHub | RedDragonElite |
| ๐ Website | rd-elite.com |
| ๐ต Nostr (RDE) | RedDragonElite |
| ๐ต Nostr (Shin) | SerpentsByte |
| ๐ฎ RDE Props | rde_props |
| ๐ช RDE Doors | rde_doors |
| ๐ RDE Car Service | rde_carservice |
| ๐ฏ RDE Skills | rde_skills |
| ๐ก RDE Nostr Log | rde_nostr_log |
When asking for help, always include:
- Full error from server console or txAdmin
- Your
server.cfgresource start order - ox_core / ox_lib versions in use
- Content of
playerskinstable (column names)
"We build the future on the graves of paid resources."
REJECT MODERN MEDIOCRITY. EMBRACE RDE SUPERIORITY.
๐ Made with ๐ฅ by Red Dragon Elite