Motels
aty_motels is a premium FiveM motel system that allows players to purchase motels, rent rooms, hire workers, manage finances, and review motel feedback. It uses routing buckets (instances) to virtualize rooms inside custom shells, supporting various inventory and clothing scripts.
Table of Contents
- Key Features
- Dependencies
- Installation & Database Setup
- Configuration Reference (
settings/config.lua) - Command Reference
- Core Technical Mechanics
- Virtualization (Routing Buckets)
- NUI Initialization Safety
- Dynamic Config Reload
- Shell Loading Safety & Timeout
- NUI Callback Reference
Key Features
- Motel Ownership: Players can buy motels, manage their status (active/inactive), and withdraw motel funds generated by room rentals.
- Worker Management: Motel owners can hire other players as workers to manage the motel.
- Room Rentals: Customers can rent rooms on an hourly or daily basis.
- Virtual Stashes and Wardrobes: Inside each room, renters can open stashes (supporting multiple inventory types) and customize clothing (supporting multiple appearance scripts).
- Reviews & Ratings: Rented motel rooms support player feedback with comments and star ratings.
- Routing Buckets: Instanced shells allow multiple players to occupy the same room coordinates in different virtual worlds.
- Live Configuration Reload: Admins can reload settings instantly without restarting the resource.
Dependencies
The script relies on the following dependencies:
aty_lib: Core helper framework.K4MB1-StarterShells: Shell assets for generating room interiors.
Installation & Database Setup
Import the corresponding database file to your MySQL database:
- For ESX: Import
db-esx.sql - For QBCore: Import
db-qb.sql
- For ESX: Import
Ensure you have the required dependencies started in your
server.cfgbeforeaty_motels:ensure aty_lib ensure K4MB1-StarterShells ensure aty_motels
Configuration Reference (settings/config.lua)
The settings/config.lua file is shared between client and server:
General Config
| Option | Type | Description |
|---|---|---|
ServerDebug |
boolean |
Activates console logging for debugging database queries and event triggers. |
Inventory |
string |
The active inventory system. Supported: "ox_inventory", "qb-inventory", "mf-inventory", "lj-inventory", "qs-inventory", "esx_inventoryhud". |
Clothing |
string |
The active clothing system. Supported: "esx_skin", "qb-clothing", "fivem-appearance", "illenium-appearance", "ox_appearance". |
OpenCabinetFromServer |
boolean |
If true, triggers the cabinet stash opening logic from the server side. |
Blips Configuration
Customizable blips for motel locations and player-owned rooms:
Blips.Motels: Customizes the map blips for all motel complexes. Color shifts dynamically depending on ownership status (Purchasable, Owned by player, or Owned by someone else).Blips.MyRoom: Customizes the blip pointing directly to the rooms rented by the player.
Integrations
Config.OpenCabinet(motelId, roomId, src, capacity): Dynamically opens stashes based on the chosen inventory system.Config.OpenClothing(motelId, roomId, src): Opens the wardrobe customization menu based on the active appearance script.
Command Reference
Player Commands
/acceptmotel: Accept an invite to join a rented room./acceptworkinvite: Accept an invite to become a motel worker.
Admin Commands
/reloadmotelconfig: Reloadssettings/config.luaon the fly. Sends the updated config string to all clients and executes it. Rebuilds blips dynamically. (Only usable by admins/gods).
Core Technical Mechanics
1. Virtualization (Routing Buckets)
When a player enters a room, the server assigns them a unique routing bucket using the pattern motelId-roomId. This prevents players inside different rooms of the same motel from seeing or colliding with each other. When exiting, the player's routing bucket is reset to the default (0).
2. NUI Initialization Safety
To prevent menu data from being lost during UI startup:
- The UI triggers a
loadedcallback once Vue mounts. - Client callbacks
openMotelMenuandopenManagementMenuverifyUILoadedis true and execute a slight delay (Wait(150)) before sending data payloads viaSendNUIMessage.
3. Dynamic Config Reload
The admin command /reloadmotelconfig uses the Lua functions load() and LoadResourceFile() to dynamically reload client and server-side configurations. This synchronizes logic changes and updates map blips instantly without resource restarts.