Skip to content

RedDragonElite/rde_sleep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

24 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ˜ด RDE SleepMod โ€” Next-Gen Sleep & Logout System

Version License FiveM ox_core Free

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


๐Ÿ“– Table of Contents


๐ŸŽฏ Overview

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.

Why RDE SleepMod?

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

โœจ Features

๐ŸŽฎ Gameplay

  • Sleeping Peds on Logout โ€” Players leave behind their character when they disconnect or use /sleeplogout
  • Full Skin Sync โ€” Appearance loaded directly from ox_core playerskins table (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

๐Ÿš€ Technical

  • 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 + PlaceObjectOnGroundProperly for 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

๐ŸŒ Quality of Life

  • 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 /sleeptest command

๐Ÿ“ฆ Dependencies

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) |


๐Ÿš€ Installation

1. Clone the repository

cd resources
git clone https://github.com/RedDragonElite/rde_sleep.git rde_sleepmod

2. Add to server.cfg

ensure 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 allow

Order matters. rde_sleepmod must start after all its dependencies.

3. Database

The rde_sleepmod table is created automatically on first start. No manual SQL import needed.

4. Configure (Optional)

Edit config.lua to adjust language, proximity distances, animation, admin permissions, and UI.

5. Restart

restart rde_sleepmod

Test with /sleeplogout in-game.


โš™๏ธ Configuration

Language & Debug

Config.DefaultLanguage = 'en'    -- 'en' or 'de'
Config.Debug           = false   -- verbose console output

Proximity & Performance

Config.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
}

Gameplay

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 weight

Animations

Config.SleepingAnimation = {
    dict = 'amb@world_human_bum_slumped@male@laying_on_left_side@base',
    clip = 'base'
}

Admin System

Config.AdminSystem = {
    acePermission = 'rde.sleepmod',
    steamIds = { 'steam:110000101605859' },
    oxGroups = { ['admin'] = 0, ['superadmin'] = 0, ['management'] = 0 },
    checkOrder = {'ace', 'oxcore', 'steam'}
}

ox_target Icons

Config.TargetIcons = {
    rob   = 'fas fa-magnifying-glass',
    carry = 'fas fa-people-carry-box',
    wake  = 'fas fa-bell',
}

Database / Skin

Config.DatabaseTable      = 'rde_sleepmod'
Config.AutoCreateTable    = true
Config.PlayerSkinsColumn  = 'citizenid'  -- Column in playerskins table (some use 'charid')

๐ŸŽฎ How It Works

For Players

  1. Disconnect or /sleeplogout โ€” Your character stays in the world as a sleeping ped
  2. Other players see you โ€” With your exact skin, clothes, tattoos, and appearance
  3. They can rob you โ€” ox_target โ†’ Rob Player โ†’ progress bar โ†’ opens your inventory stash
  4. They can carry you โ€” ox_target โ†’ Carry Player โ†’ fireman's carry โ†’ [E] to release
  5. You log back in โ€” Your sleeping ped is automatically removed

For Admins

  • Wake Players โ€” ox_target โ†’ Wake Player (admin-only option, triple-verified)
  • Debug โ€” /sleeptest shows spawned peds and GlobalState count

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     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 System

Admin access uses triple verification โ€” checked in configurable order:

Method 1: ACE Permissions (Recommended)

# server.cfg
add_ace group.admin rde.sleepmod allow

Method 2: ox_core Groups

Config.AdminSystem.oxGroups = {
    ['admin'] = 0,
    ['superadmin'] = 0,
}

Method 3: Steam ID Whitelist

Config.AdminSystem.steamIds = {
    'steam:110000101605859',
}

๐Ÿ”ง Developer API

Exports (Server)

-- 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')

Exports (Client)

-- Check if an entity is a sleeping clone
local isSleeping = exports.rde_sleepmod:IsClone(entity)
local isSleeping = exports.rde_sleepmod:IsSleepingClone(entity)

GlobalState

-- Read sleeping player positions from any client
local sleepers = GlobalState.sleepingPlayers
-- Returns: { ['DM1881'] = { x, y, z, w, model }, ... }

๐Ÿ—„๏ธ Database

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.


โšก Performance

Architecture Advantages

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)

Benchmarks

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

Why So Fast?

  • 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

๐Ÿ› Troubleshooting

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.


๐Ÿ“‹ Commands

Command Access Description
/sleeplogout Player Create sleeping ped and logout
/sleeptest Debug only Print spawned ped and GlobalState counts

๐Ÿ“ Changelog

v1.1.0 โ€” Current

  • 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

v1.0.0

  • Proximity-loaded sleeping peds (rde_props pattern)
  • GlobalState sync โ€” zero network events
  • Full skin sync from playerskins table
  • 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

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Commit: git commit -m 'Add your feature'
  4. Push: git push origin feature/your-feature
  5. Open a Pull Request

Guidelines: follow existing Lua conventions, comment complex logic, test on a live server before PR, update docs if adding features.


๐Ÿ“œ License

###################################################################################
#                                                                                 #
#      .:: 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

๐Ÿ“ File Structure

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

๐ŸŒ Community & Support

๐Ÿ™ 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.cfg resource start order
  • ox_core / ox_lib versions in use
  • Content of playerskins table (column names)

"We build the future on the graves of paid resources."

REJECT MODERN MEDIOCRITY. EMBRACE RDE SUPERIORITY.

๐Ÿ‰ Made with ๐Ÿ”ฅ by Red Dragon Elite

โฌ† Back to Top

About

๐Ÿ˜ด RDE SleepMod โ€” Next-Gen Sleep & Logout System. 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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages