Hotel Script | Fivem

if roomNumber == nil then -- Find free room MySQL.query('SELECT room_number FROM hotel_rentals WHERE paid_until > ?', {os.time()}, function(occupied) local occupiedRooms = {} for _, v in pairs(occupied) do occupiedRooms[v.room_number] = true end

-- Helper functions function getIdentifier(source) if Config.Framework == 'esx' then local xPlayer = ESX.GetPlayerFromId(source) return xPlayer.identifier else local Player = QBCore.Functions.GetPlayer(source) return Player.PlayerData.citizenid end end hotel script fivem

-- Check if player already has a room RegisterNetEvent('hotel:checkRentStatus') AddEventHandler('hotel:checkRentStatus', function() local src = source local identifier = getIdentifier(src) if roomNumber == nil then -- Find free room MySQL

function removeMoney(source, amount) if Config.Framework == 'esx' then local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.getMoney() >= amount then xPlayer.removeMoney(amount) return true end else local Player = QBCore.Functions.GetPlayer(source) if Player.Functions.RemoveMoney('cash', amount) then return true end end return false end Config.ReceptionNPC.coords.z - 1.0

-- Payment interval (in minutes) Config.PaymentInterval = 60

-- Spawn reception NPC Citizen.CreateThread(function() local model = Config.ReceptionNPC.model RequestModel(model) while not HasModelLoaded(model) do Citizen.Wait(10) end local npc = CreatePed(4, model, Config.ReceptionNPC.coords.x, Config.ReceptionNPC.coords.y, Config.ReceptionNPC.coords.z - 1.0, Config.ReceptionNPC.coords.w, false, true) SetEntityInvincible(npc, true) FreezeEntityPosition(npc, true) SetBlockingOfNonTemporaryEvents(npc, true)

-- Room prices Config.RoomPrice = 500 -- per payment interval