Pink Cage Motel apartments?

i got a problem with my lsrp-motels i do everything but i saw that on my console and when i rent a house nothing is changing i cant rent a property

Console Log:
Error: (node:11276) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
at Function.values ()
at execute.then (mysql-async.js:5002:48)
Error: (node:11276) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 5)

sorry dit not know i just found this link in other topic

Im trying figured that out too… so far i have this:

When the player enter the server it checks if he already have a room on the motel.

I’ve created two tables on the database one for all pinkcage motel rooms(pinkcage_rooms) and other to assign the room to the player(owned_rooms) like properties.

Now i need a way to get all motel rooms and give 1 random room to that player, then display the marker for him… Almost there i think.

client.lua

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)

  ESX.TriggerServerCallback('esx_pinkcage:checkIfPlayerHaveRoom', function(ownedRooms)
    if rooms == nil then
      ESX.TriggerServerCallback('esx_pinkcage:giveRoom', function()
          
      end)
    end
  end)

server.lua

ESX.RegisterServerCallback('esx_pinkcage:checkIfPlayerHaveRoom', function(source, cb, owner)

  local xPlayer = ESX.GetPlayerFromId(source)

  MySQL.Async.fetchAll(
    'SELECT * FROM owned_rooms WHERE owner = @owner',
    {
      ['@owner'] = xPlayer.identifier
    },
    function(ownedRooms)

      local rooms = {}

      for i=1, #ownedRooms, 1 do
        table.insert(rooms, ownedRooms[i].name)
      end

      cb(rooms)

    end
  )

end)

what you think? i think if we get together we can do it easily :slight_smile:

What are you storing bound to motel rooms that you need to use a database table?

Can just use client IDs and store door locations in a list and use the client ID to index the list to set the entry point. You’re overcomplicating an honestly extremely simple thing.

1 Like

I understand what u are saying… But im new to lua and databases related things. My idea was if i creat a good solution, maybe in the future realese it, and its look like more organized that way for me.

And my logic was to have like 30+ rooms and get one random room to a new player. I think it was more simple to have all rooms stored in a new table to search from and manage this process.

Yeah, I mean it depends what you’re wanting the behavior to be. You’re likely going to have more than 32 unique players logging in over the lifetime of your server so you’ll either use the same door for some people or end up having to use their Client ID anyways to determine where they enter and at that point there’s no real reason to use a DB Table as you’re adding extra overhead by making a DB Call for no real benefit (Albeit it’d likely be negligible).

My apartment script, I’m not using Pink Cage but the general idea is the same just different coords.

2 Likes

does not require sql

Where is sql i?

It doesn’t use SQL as there is no reason?

It’s not a drag & drop, so suggest against trying to do it.

http://prntscr.com/o31goi how to add ?

Mythic Base …

The UI is released on Github, but it is not changed from how it’s implemented in my framework which isn’t released so if you want it you’d have to modify it yourself to get it to work

give me please bro :slight_smile:

Give you what? The UI link? Click the git repo above and click on mythicrp and it’ll be on there.

i need e mystic base

Not released, sorry

pleasee bro :confused:

Love your script, i will wait for an official release thread …
(I will have a question, if the bug is still there… an opening the bed stash error… from an older version of your now dead github)

anyone know how to go about coding in a way to make it so you can only rent one property at a time? or maybe make it so on load in you automatically get a motel room for that session?

Hey @Ceenga.did you manage to solve the problem ? if you do how you do ?

Got The Motels In But the storage is abit confusing bc iwant it so that the hotel rooms ahve a differen storage space to other apartments that players own so that they can use one as a storage stash for illegal stuff if you understand what i mean. if anyone could help that would be great.