Hotel Script Fivem Link

server_scripts { 'config.lua', 'server.lua' }

shared_scripts { '@ox_lib/init.lua', -- optional but recommended '@es_extended/imports.lua' -- if using ESX }

dependencies { 'es_extended', -- or 'qb-core' 'ox_target' -- or 'qb-target' } Config = {} -- Framework: 'esx' or 'qb' Config.Framework = 'esx' 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.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 server_scripts { 'config

-- NUI callback for payment RegisterNUICallback('payRoom', function(data, cb) SetNuiFocus(false, false) TriggerServerEvent('hotel:payRent', data.room, data.price) cb('ok') end)

-- Door lock control (use ox_doorlock or custom) Config.UseAdvancedLock = false server_scripts { 'config.lua'

-- 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)