DOCUMENTATION
  • 🌐INTRODUCTION
  • â„šī¸INFORMATION
  • 💲PAID SCRIPTS
    • 🎧Surround (Spatial Audio)
      • Introduction
      • Installation
      • API
        • Client
          • Set
          • Get
          • Handlers
        • Server
          • Set
          • Get
        • Shared
      • Examples
    • 🏨Motels
      • Introduction
        • Motel Manager
        • Customer
        • Rent Cycle
        • Share Key
        • Auto System
        • Admin
        • Logs
        • Configurable Codes
        • Optimization
      • Installation
  • 🆓FREE SCRIPTS
    • FiveM Manager Bot
      • INSTALLATION
Powered by GitBook
On this page
  • Client Side
  • Server Side
  • Example Code

Was this helpful?

  1. PAID SCRIPTS
  2. Motels
  3. Introduction

Optimization

About the optimization

PreviousConfigurable CodesNextInstallation

Last updated 1 year ago

Was this helpful?

Client Side

IDLE

When Nearby A Room

When Nearby The Text And Marker

Server Side

All Sql Queries Are Perfectly Optimized

Example Code

function SaveCustomers()
    if next(PlayersMotels) then
        local selectList = ''
        local formatQuery = ([[
            SELECT '%s' AS owner, %s AS py, '%s' AS mtl, %s AS rmid, '%s' AS unq, '%s' AS reqs, %s as susp, '%s' as sh, %s as st, %s as ed, '%s' as wn
        ]])
        local total = 0
        for k,v in pairs(PlayersMotels) do
            total+= 1
            if selectList == '' then 
                selectList = ([[
                    UPDATE mx_motels u JOIN (%s
                ]]):format(formatQuery:format(k, v.pay, v.motel, v.roomId, v.uniq, json.encode(v.requests), v.suspended, json.encode(v.shared), v.startTime, v.endTime, json.encode(v.warn)))
                goto continue
            end
            selectList = selectList .. ([[
                UNION %s
            ]]):format(formatQuery:format(k, v.pay, v.motel, v.roomId, v.uniq, json.encode(v.requests), v.suspended, json.encode(v.shared), v.startTime, v.endTime, json.encode(v.warn)))
            ::continue::
        end
        if selectList == '' then return end
        selectList = selectList .. [[
            ) AS t ON u.owner = t.owner
           SET pay = py,
            motel = mtl, 
            `roomId` = rmid,
            uniq = unq,
            requests = reqs,
            suspended = susp,
            `shared` = sh,
            `startTime` = st,
            `endTime` = ed,
            `warn` = wn
        ]]
        ExecuteSQL(selectList)
        Debug('Saved ^2'..total..'^1 Customers(s) ^0')
    end
end
💲
🏨