Commands#
Motels Creator registers three in-game commands and one console command.
Command | Where | Description |
|---|---|---|
| In game | Opens or closes the creator. Admins and |
| In game |

Documentation
Every Motels Creator command, plus the client and server exports, the ServerMotelManager API, net events and callbacks for reading rentals, evicting tenants and renting rooms from a phone.
Motels Creator registers three in-game commands and one console command.
Command | Where | Description |
|---|---|---|
| In game | Opens or closes the creator. Admins and |
| In game |
Raids the nearest room. Jobs in |
| In game | Steps through the nearest MLO room door — for doors whose collision traps players. |
| Console | Saves every motel, rental and worker now — run it before a restart. The name is |
Everything else is done in the interface. Giving a motel to a player, removing an owner or deleting a motel happens in the creator, not by command.
For HUDs, phones, radial menus and other scripts that need to know where a player sleeps.
-- The room the player is inside right now, or nil
local room = exports['qs-motels-creator']:getCurrentRoom()
-- The player's rental, or nil
-- { id, motel_id, room_id, tenant_identifier, rent_debt, is_suspended, start_time, end_time, ... }
local rental = exports['qs-motels-creator']:getPlayerRental()
if rental then
print(('Room %s, %s seconds left'):format(rental.room_id, rental.end_time - GetCloudTimeAsInt()))
endThe client-side store of every motel, with lookup helpers:
local motels = exports['qs-motels-creator']:getMotelManager()
motels:get(motelId) -- one motel
motels:getAll() -- every motel, keyed by id
motels:getByLabel('Richman Motel')
motels:getCurrentMotel() -- the motel zone the player stands in
motels:getNearbyMotel() -- the closest motel
motels:getNearbyMotelId()
motels:getPlayerRental()
motels:getRentalAtMotel(motelId)
motels:getRentalCount()
motels:isWorkerAt(motelId) -- employee or owner there?
motels:getWorkerAt(motelId) -- { salary, permissions, ... }
motels:getPlayerWorker()
motels:hasKeyFor(motelId, roomIndex) -- tenant or shared guest
motels:getSharedKeyData(motelId, roomIndex)-- Start a raid on the nearest room (job check included)
exports['qs-motels-creator']['motels:raid']()
-- ox_inventory only: the key item's client export
-- client = { export = 'qs-motels-creator.motels:UseKey' }Other resources can also trigger the raid with the client event motels:raid, and on every inventory except ox the key is used through the client event motels:UseKey.
How another resource acts on a tenant — an eviction script, a court sentence, an admin panel.
Ends a player's rental: the room is locked and freed, and the tenant, if online, is told.
-- identifier: ESX identifier or QBCore citizenid
exports['qs-motels-creator']:kickCustomer(identifier)From the editable files in server/custom/ the whole server state is available through the global ServerMotelManager — the same object the reception uses. Write through it, not to the database, or the change is overwritten on the next save.
ServerMotelManager:getMotel(motelId)
ServerMotelManager:getAllMotels()
ServerMotelManager:getMotelsByOwner(identifier)
ServerMotelManager:refreshMotel(motelId) -- reload from the database
ServerMotelManager:syncMotel(motelId) -- reload and push to every client
ServerMotelManager:saveAll()
ServerMotelManager:getEmptyRoomCount(motelId)
ServerMotelManager:getTenantCount(motelId)
ServerMotelManager:getWorkerCount(motelId)ServerMotelManager:getRentals(motelId)
ServerMotelManager:getRental(motelId, roomIndex)
ServerMotelManager:getRentalByIdentifier(identifier) --> rental, motelId
ServerMotelManager:getRentalsByIdentifier(identifier)
ServerMotelManager:getRentalCountByIdentifier(identifier)
ServerMotelManager:getRentalByIdentifierAtMotel(identifier, motelId)
ServerMotelManager:isRoomAvailable(motelId, roomIndex)
ServerMotelManager:getEmptyRooms(motelId)
ServerMotelManager:rentRoom(motelId, roomIndex, identifier, name, durationMs, debt) --> ok, rental
ServerMotelManager:leaveRoom(motelId, roomIndex)
ServerMotelManager:saveRental(rental)ServerMotelManager:hasKey(identifier, motelId, roomId)
ServerMotelManager:getKeyShares(motelId, roomId)
ServerMotelManager:getKeyShareCount(motelId, roomId)
ServerMotelManager:shareKeyWithPermissions(motelId, roomId, ownerId, guestId, guestName, permissions)
ServerMotelManager:updateKeySharePermissions(shareId, permissions)
ServerMotelManager:revokeKeyShare(shareId)
ServerMotelManager:removeAllKeyShares(motelId, roomId)
ServerMotelManager:getGuestAccess(guestIdentifier)
ServerMotelManager:hasGuestPermission(guestIdentifier, motelId, roomId, 'stash_access')
ServerMotelManager:getSharedRoomsForPlayer(identifier)ServerMotelManager:getWorkers(motelId)
ServerMotelManager:getWorker(motelId, identifier)
ServerMotelManager:getWorkerByIdentifier(identifier) --> worker, motelId
ServerMotelManager:getAllWorkersByIdentifier(identifier)
ServerMotelManager:addWorker(motelId, identifier, name, salary, permissions, isOwner)
ServerMotelManager:removeWorker(motelId, identifier)
ServerMotelManager:isOwner(motelId, identifier)
ServerMotelManager:isOwnerOrWorker(motelId, identifier)
ServerMotelManager:hasPermission(motelId, identifier, 'kick') -- owners always trueServerMotelManager:getBalance(motelId)
ServerMotelManager:deposit(motelId, amount, description, identifier, name)
ServerMotelManager:withdraw(motelId, amount, description, identifier, name) --> false if short
ServerMotelManager:getBills(identifier)
ServerMotelManager:hasBills(identifier)
ServerMotelManager:createBill(identifier, motelId, amount, description)
ServerMotelManager:payBill(identifier, billId)
ServerMotelManager:createRequest(motelId, roomId, identifier, name, message)
ServerMotelManager:resolveRequest(requestId, 'accepted') -- or 'rejected'
ServerMotelManager:getPendingRequests(motelId)
ServerMotelManager:createNotification(motelId, roomId, identifier, 'warning', message)Shared by client and server, so a price shown is the price charged:
GetRentUnitMs(motel) -- 3600000 (hour) or 86400000 (day)
ComputeRentPrice(motel, durationMs) -- price × units, rounded up to whole units
GetMinRentDurationMs(motel) -- one unit
GetMaxRentDurationMs(motel) -- 336 hours or 30 days
IsValidRentDuration(motel, durationMs)Client events your resource can listen to:
Event | Arguments | Fired when |
|---|---|---|
| motelId, roomIndex, rental | The player rented, paid, extended, changed room or got a new key. |
| motelId, roomIndex | The player left, was kicked or the rental expired. |
| { motelId, roomId, level, message } | A rent warning was issued. |
| motelId, identifier, name | A motel was bought or sold (owner nil when sold). |
| motelId, roomIndex, pointType, pointIndex, locked | A door, stash or wardrobe was locked or unlocked. |
| msg, type | Any message for the player. |
Server events are not an API. Every
motels:*server event re-checks the player's identity, permissions and the price itself, so triggering one on behalf of someone else does nothing. Use the exports and callbacks.
Built for phone apps: called from the player's client with ox_lib, checked and priced on the server.
local cb = lib.callback.await
-- Motels on the map, the player's rentals, shared rooms and staff roles
local boot = cb('motels:phone:getBootstrap', false)
-- Rooms of one motel and whether each is free
local rooms = cb('motels:phone:getMotelRooms', false, motelId)
-- The server's price for a duration
local quote = cb('motels:phone:quoteRent', false, motelId, roomIndex, durationMs)
-- Rent: { ok = true, rental = {...} } or { ok = false, error = 'room_taken' }
local result = cb('motels:phone:rentRoom', false, motelId, roomIndex, durationMs)
-- Staff: pending requests, and answering one
local reqs = cb('motels:phone:getStaffRequests', false, motelId)
cb('motels:phone:resolveRequest', false, requestId, 'accepted') -- or 'rejected'A refused rental returns one of these codes:
Code | Means |
|---|---|
| Wrong motel id, or a missing argument. |
| Shorter than one unit or longer than the maximum. |
| The room is beyond the motel's room capacity. |
| Someone rents it already. |
| The player owes a bill. |
| One room per motel, or the global limit reached. |
| Not enough cash (when rent is paid up front). |
| The player is not fully loaded, or the write failed. |