local QBCore = exports['qb-core']:GetCoreObject() local InRoom = false local currentInvite = nil -- Coordinates of the motel local motelCoords = Config.MotelCoords local inviteRadius = 10.0 local function playNotificationSound() PlaySoundFrontend(-1, "SHOOTING_RANGE_ROUND_OVER", "HUD_AWARDS", 1) end -- Create a thread for adding blip CreateThread(function() if Config.Blips then fastmotels = AddBlipForCoord(Config.MotelCoords.x, Config.MotelCoords.y, Config.MotelCoords.z) SetBlipSprite(fastmotels, Config.BlipSprite) SetBlipDisplay(fastmotels, 4) SetBlipScale(fastmotels, Config.BlipScale) SetBlipColour(fastmotels, Config.BlipColour) SetBlipAsShortRange(fastmotels, true) BeginTextCommandSetBlipName("STRING") AddTextComponentString(Config.BlipName) EndTextCommandSetBlipName(fastmotels) end end) -- Create motel ped local motelPedCoords = vector3(Config.MotelCoords.x, Config.MotelCoords.y, Config.MotelCoords.z) local pedModel = "s_m_m_highsec_01" local pedHash = GetHashKey(pedModel) RequestModel(pedHash) while not HasModelLoaded(pedHash) do Wait(1) end local motelPed = CreatePed(4, pedHash, motelPedCoords.x, motelPedCoords.y, motelPedCoords.z, Config.MotelCoordsHead, false, true) SetEntityInvincible(motelPed, true) FreezeEntityPosition(motelPed, true) SetBlockingOfNonTemporaryEvents(motelPed, true) -- Add target entity options exports['qb-target']:AddTargetEntity(motelPed, { options = { { type = "client", event = "rafializade-motels:openMotelMenu", icon = "fas fa-hotel", label = "Motel Seçenekleri", }, { type = "client", event = "rafializade-motels:showInvites", icon = "fas fa-user-plus", label = "Davet Edilen Odalar", } }, distance = 2.0 }) -- Event to receive player names from the server RegisterNetEvent('rafializade-motels:receivePlayerNames') AddEventHandler('rafializade-motels:receivePlayerNames', function(playerNames) local playerOptions = {} for _, player in pairs(playerNames) do local playerCoords = vector3(player.coords.x, player.coords.y, player.coords.z) local distance = #(playerCoords - motelCoords) if distance <= inviteRadius then table.insert(playerOptions, { header = player.name, txt = "Oyuncuyu davet et", params = { event = "rafializade-motels:sendInvite", args = { target = player.id, } } }) end end if #playerOptions > 0 then exports['qb-menu']:openMenu({ { header = "Davet Et", isMenuHeader = true }, table.unpack(playerOptions), { header = "Menüyü Kapat", icon = "fas fa-xmark", params = { event = "" } } }) else QBCore.Functions.Notify("Etrafta başka oyuncu yok.", "error") end end) -- Event to request player names for inviting RegisterNetEvent('rafializade-motels:invitePlayer') AddEventHandler('rafializade-motels:invitePlayer', function() TriggerServerEvent('rafializade-motels:requestPlayerNames') end) -- Event to send invite to the server RegisterNetEvent('rafializade-motels:sendInvite') AddEventHandler('rafializade-motels:sendInvite', function(data) TriggerServerEvent('rafializade-motels:sendInvite', data) end) -- Event to receive invite from another player RegisterNetEvent('rafializade-motels:receiveInvite') AddEventHandler('rafializade-motels:receiveInvite', function(inviterName, inviterId, inviterCoords) local playerCoords = GetEntityCoords(PlayerPedId()) local distance = #(playerCoords - motelCoords) -- print("Received invite from", inviterName, "at coords", inviterCoords) if distance <= inviteRadius then currentInvite = { inviterName = inviterName, inviterId = inviterId, inviterCoords = inviterCoords } QBCore.Functions.Notify(inviterName .. " sizi motel odasına davet etti.", "info", 5000) playNotificationSound() else TriggerServerEvent('rafializade-motels:inviteeTooFar', inviterId) end end) RegisterNetEvent('rafializade-motels:showInviteNotification') AddEventHandler('rafializade-motels:showInviteNotification', function(inviterName, inviterId, inviterCoords) exports['qb-menu']:openMenu({ { header = "Davet Edilen Odalar", isMenuHeader = true }, { header = inviterName .. " tarafından davet edildiniz", txt = "Daveti kabul etmek için tıklayın", params = { event = "rafializade-motels:acceptInvite", args = { inviterId = inviterId, inviterCoords = inviterCoords } } }, { header = "Menüyü Kapat", icon = "fas fa-xmark", params = { event = "" } } }) end) -- Event to manually check invites RegisterNetEvent('rafializade-motels:showInvites') AddEventHandler('rafializade-motels:showInvites', function() if currentInvite then TriggerEvent('rafializade-motels:showInviteNotification', currentInvite.inviterName, currentInvite.inviterId, currentInvite.inviterCoords) else QBCore.Functions.Notify("Davet verisi bulunamadı.", "error", 5000) end end) -- Event to handle no invites scenario RegisterNetEvent('rafializade-motels:noInvites') AddEventHandler('rafializade-motels:noInvites', function() exports['qb-menu']:openMenu({ { header = "Davet Edilen Odalar", isMenuHeader = true }, { header = "Hiçbir davetiniz yok.", txt = "Şu anda size gönderilmiş bir davet bulunmamaktadır." }, { header = "Menüyü Kapat", icon = "fas fa-xmark", params = { event = "" } } }) end) RegisterNetEvent('rafializade-motels:acceptInvite') AddEventHandler('rafializade-motels:acceptInvite', function(data) -- print("Accepting invite with data:", data) TriggerServerEvent('rafializade-motels:acceptInvite', data.inviterId, data.inviterCoords) currentInvite = nil -- Clear the invite data after acceptance end) -- Event handler for teleporting to invited room RegisterNetEvent('rafializade-motels:teleportToCoords') AddEventHandler('rafializade-motels:teleportToCoords', function(coords) -- print("Teleporting to coords:", coords) if coords then DoScreenFadeOut(1000) Wait(1000) SetEntityCoords(PlayerPedId(), coords.x, coords.y, coords.z, false, false, false, true) InRoom = true -- Büyük harfle InRoom kullanıyoruz, scriptin geri kalanıyla uyumlu olması için Wait(1000) DoScreenFadeIn(1000) else -- print("Error: Teleport coordinates are nil") end end) RegisterNetEvent("rafializade-motels:openMotelMenu") AddEventHandler("rafializade-motels:openMotelMenu", function() exports['qb-menu']:openMenu({ { header = 'Motel Menüsü', icon = 'fas fa-hotel', isMenuHeader = true, }, { header = 'Odana Gir', txt = 'Sahip olduğunuz motel odasına girer', icon = 'fas fa-key', params = { event = 'rafializade-motels:enterRoom' } }, { header = 'Motel Odası Satın Al', txt = 'Yeni motel odası satın almanızı sağlar', icon = 'fas fa-sack-dollar', params = { event = 'rafializade-motels:buyRoomMenu' } }, { header = 'Menüyü Kapat', txt = 'Motel menüsünü kapatır', icon = 'fas fa-right-to-bracket', params = { event = '' } }, }) end) RegisterNetEvent("rafializade-motels:buyRoomMenu") AddEventHandler("rafializade-motels:buyRoomMenu", function() local menuItems = { { header = 'Oda Satın Alım Menüsü', icon = 'fas fa-hotel', isMenuHeader = true, } } if Config.BasicRoomEnabled then table.insert(menuItems, { header = Config.BasicRoomText, txt = 'Ücret: '.. tostring(Config.BasicRoomPrice) .. " $", icon = 'fas fa-sack-dollar', params = { event = 'rafializade-motels:buyBasicRoom' } }) end if Config.Room1Enabled then table.insert(menuItems, { header = Config.Room1Text, txt = 'Ücret: '.. tostring(Config.Room1Price) .. " $", icon = 'fas fa-sack-dollar', params = { event = 'rafializade-motels:buyRoom1' } }) end if Config.Room2Enabled then table.insert(menuItems, { header = Config.Room2Text, txt = 'Ücret: '.. tostring(Config.Room2Price) .. " $", icon = 'fas fa-sack-dollar', params = { event = 'rafializade-motels:buyRoom2' } }) end table.insert(menuItems, { header = 'Geri dön', txt = 'Motel menüsüne geri döner', icon = 'fas fa-right-to-bracket', params = { event = "rafializade-motels:openMotelMenu" } }) exports['qb-menu']:openMenu(menuItems) end) RegisterNetEvent("rafializade-motels:buyBasicRoom") AddEventHandler("rafializade-motels:buyBasicRoom", function() TriggerServerEvent("rafializade-motels:buyRoom", "basic") end) RegisterNetEvent("rafializade-motels:buyRoom1") AddEventHandler("rafializade-motels:buyRoom1", function() TriggerServerEvent("rafializade-motels:buyRoom", "room1") end) RegisterNetEvent("rafializade-motels:buyRoom2") AddEventHandler("rafializade-motels:buyRoom2", function() TriggerServerEvent("rafializade-motels:buyRoom", "room2") end) function OpenMotelStash() local PlayerData = QBCore.Functions.GetPlayerData() if Config.Inventory == "qb" then TriggerEvent("inventory:client:SetCurrentStash", "Motel_"..PlayerData.citizenid) TriggerServerEvent("inventory:server:OpenInventory", "stash", "Motel_"..PlayerData.citizenid) elseif Config.Inventory == "ox" then TriggerServerEvent("rafializade-motels:registerstash", "Motel_"..PlayerData.citizenid) exports.ox_inventory:openInventory('stash', {id = "Motel_"..PlayerData.citizenid, owner = PlayerData.citizenid}) else return end end function OpenOutfitMenu() TriggerEvent("qb-clothing:client:openOutfitMenu") end function BasicRoom() InRoom = true FreezeEntityPosition(PlayerPedId(), true) DoScreenFadeOut(1000) Wait(1000) SetEntityCoords(PlayerPedId(), Config.BasicRoomCoords.x, Config.BasicRoomCoords.y, Config.BasicRoomCoords.z, false) SetEntityHeading(PlayerPedId(), 171.61) Wait(2000) FreezeEntityPosition(PlayerPedId(), false) Wait(1000) DoScreenFadeIn(1000) end function Room1() InRoom = true FreezeEntityPosition(PlayerPedId(), true) DoScreenFadeOut(1000) Wait(1000) SetEntityCoords(PlayerPedId(), Config.Room1Coords.x, Config.Room1Coords.y, Config.Room1Coords.z, false) SetEntityHeading(PlayerPedId(), 0.19) Wait(2000) FreezeEntityPosition(PlayerPedId(), false) Wait(1000) DoScreenFadeIn(1000) end function Room2() InRoom = true FreezeEntityPosition(PlayerPedId(), true) DoScreenFadeOut(1000) Wait(1000) SetEntityCoords(PlayerPedId(), Config.Room2Coords.x, Config.Room2Coords.y, Config.Room2Coords.z, false) SetEntityHeading(PlayerPedId(), 353.9) Wait(2000) FreezeEntityPosition(PlayerPedId(), false) Wait(1000) DoScreenFadeIn(1000) end RegisterNetEvent("rafializade-motels:enterRoom") AddEventHandler("rafializade-motels:enterRoom", function() TriggerServerEvent("rafializade-motels:datacheck") end) RegisterNetEvent("rafializade-motels:teleportRoom") AddEventHandler("rafializade-motels:teleportRoom", function(motel_type_data) -- print('salam') local motel_type = motel_type_data if motel_type == "basic" then BasicRoom() elseif motel_type == "room1" then Room1() elseif motel_type == "room2" then Room2() else -- print("[DEBUG]: data bulunamadi") QBCore.Functions.Notify("Motel datanız bulunamadı sunucu sahibi ile iletisime gecin", "error", 5000) end end) CreateThread(function() while true do local sleep = 1000 local distance = #(Config.BasicRoomStash - GetEntityCoords(PlayerPedId())) if InRoom then if distance <= 2 then sleep = 1 QBCore.Functions.DrawText3D(Config.BasicRoomStash.x, Config.BasicRoomStash.y, Config.BasicRoomStash.z, "[E] - Depo") if IsControlJustPressed(0, 38) then OpenMotelStash() end end end Wait(sleep) end end) CreateThread(function() local sleep = 1000 local zoneCreated = false -- Zone'un oluşturulup oluşturulmadığını takip etmek için flag while true do if InRoom then local playerCoords = GetEntityCoords(PlayerPedId()) local distance = #(Config.BasicRoomDoor - playerCoords) if distance <= 2 then sleep = 1 if not zoneCreated then -- Eğer zone henüz oluşturulmamışsa exports['qb-target']:AddBoxZone("basic_motel_door", vector3(Config.BasicRoomDoor.x, Config.BasicRoomDoor.y, Config.BasicRoomDoor.z), 1, 1, { name = "basic_motel_door", heading = 0, debugPoly = false, minZ = Config.BasicRoomDoor.z - 1.0, maxZ = Config.BasicRoomDoor.z + 1.0 }, { options = { { type = "client", action = function() ExitRoom() end, icon = "fas fa-door-open", label = "Otelden Çıkış", }, { type = "client", event = "rafializade-motels:invitePlayer", icon = "fas fa-user-plus", label = "Odaya Davet Et", } }, distance = 2.0 } ) zoneCreated = true -- Zone'u oluşturduktan sonra flag'i true yap end else if zoneCreated then -- Eğer zone oluşturulmuşsa ve mesafe uzaksa exports['qb-target']:RemoveZone("basic_motel_door") zoneCreated = false -- Zone'u kaldırdıktan sonra flag'i false yap end sleep = 1000 end else if zoneCreated then -- Odadan çıkıldığında zone'u temizle exports['qb-target']:RemoveZone("basic_motel_door") zoneCreated = false end sleep = 1000 end Wait(sleep) end end) CreateThread(function() local sleep = 1000 local zoneCreated = false -- Zone'un oluşturulup oluşturulmadığını takip etmek için flag while true do if InRoom then local playerCoords = GetEntityCoords(PlayerPedId()) local distance = #(Config.Room1DoorCoords - playerCoords) if distance <= 2 then sleep = 1 if not zoneCreated then -- Eğer zone henüz oluşturulmamışsa exports['qb-target']:AddBoxZone("basicroom1_motel_door", vector3(Config.Room1DoorCoords.x, Config.Room1DoorCoords.y, Config.Room1DoorCoords.z), 1, 1, { name = "basicroom1_motel_door", heading = 0, debugPoly = false, minZ = Config.Room1DoorCoords.z - 1.0, maxZ = Config.Room1DoorCoords.z + 1.0 }, { options = { { type = "client", action = function() ExitRoom() end, icon = "fas fa-door-open", label = "Otelden Çıkış", }, { type = "client", event = "rafializade-motels:invitePlayer", icon = "fas fa-user-plus", label = "Odaya Davet Et", } }, distance = 2.0 } ) zoneCreated = true -- Zone'u oluşturduktan sonra flag'i true yap end else if zoneCreated then -- Eğer zone oluşturulmuşsa ve mesafe uzaksa exports['qb-target']:RemoveZone("basicroom1_motel_door") zoneCreated = false -- Zone'u kaldırdıktan sonra flag'i false yap end sleep = 1000 end else if zoneCreated then -- Odadan çıkıldığında zone'u temizle exports['qb-target']:RemoveZone("basicroom1_motel_door") zoneCreated = false end sleep = 1000 end Wait(sleep) end end) CreateThread(function() local sleep = 1000 local zoneCreated = false -- Zone'un oluşturulup oluşturulmadığını takip etmek için flag while true do if InRoom then local playerCoords = GetEntityCoords(PlayerPedId()) local distance = #(Config.Room2DoorCoords - playerCoords) if distance <= 2 then sleep = 1 if not zoneCreated then -- Eğer zone henüz oluşturulmamışsa exports['qb-target']:AddBoxZone("basicroom2_motel_door", vector3(Config.Room2DoorCoords.x, Config.Room2DoorCoords.y, Config.Room2DoorCoords.z), 1, 1, { name = "basicroom2_motel_door", heading = 0, debugPoly = false, minZ = Config.Room2DoorCoords.z - 1.0, maxZ = Config.Room2DoorCoords.z + 1.0 }, { options = { { type = "client", action = function() ExitRoom() end, icon = "fas fa-door-open", label = "Otelden Çıkış", }, { type = "client", event = "rafializade-motels:invitePlayer", icon = "fas fa-user-plus", label = "Odaya Davet Et", } }, distance = 2.0 } ) zoneCreated = true -- Zone'u oluşturduktan sonra flag'i true yap end else if zoneCreated then -- Eğer zone oluşturulmuşsa ve mesafe uzaksa exports['qb-target']:RemoveZone("basicroom2_motel_door") zoneCreated = false -- Zone'u kaldırdıktan sonra flag'i false yap end sleep = 1000 end else if zoneCreated then -- Odadan çıkıldığında zone'u temizle exports['qb-target']:RemoveZone("basicroom2_motel_door") zoneCreated = false end sleep = 1000 end Wait(sleep) end end) CreateThread(function() while true do local sleep = 1000 local distance = #(Config.BasicRoomOutfit - GetEntityCoords(PlayerPedId())) if InRoom then if distance <= 2 then sleep = 1 QBCore.Functions.DrawText3D(Config.BasicRoomOutfit.x, Config.BasicRoomOutfit.y, Config.BasicRoomOutfit.z, "[E] - Kıyafet Dolabı") if IsControlJustPressed(0, 38) then OpenOutfitMenu() end end end Wait(sleep) end end) -- CreateThread(function() -- while true do -- local sleep = 1000 -- local distance = #(Config.BasicRoomDoor - GetEntityCoords(PlayerPedId())) -- if InRoom then -- if distance <= 2 then -- sleep = 1 -- -- QBCore.Functions.DrawText3D(Config.BasicRoomDoor.x, Config.BasicRoomDoor.y, Config.BasicRoomDoor.z, "[E] - Odadan Çık") -- if IsControlJustPressed(0, 38) then -- ExitRoom() -- end -- end -- end -- Wait(sleep) -- end -- end) -- CreateThread(function() -- while true do -- local sleep = 1000 -- local distance = #(Config.Room1DoorCoords - GetEntityCoords(PlayerPedId())) -- if InRoom then -- if distance <= 2 then -- sleep = 1 -- -- QBCore.Functions.DrawText3D(Config.Room1DoorCoords.x, Config.Room1DoorCoords.y, Config.Room1DoorCoords.z, "[E] - Odadan Çık") -- if IsControlJustPressed(0, 38) then -- ExitRoom() -- end -- end -- end -- Wait(sleep) -- end -- end) CreateThread(function() while true do local sleep = 1000 local distance = #(Config.Room1Stash - GetEntityCoords(PlayerPedId())) if InRoom then if distance <= 2 then sleep = 1 QBCore.Functions.DrawText3D(Config.Room1Stash.x, Config.Room1Stash.y, Config.Room1Stash.z, "[E] - Depo") if IsControlJustPressed(0, 38) then OpenMotelStash() end end end Wait(sleep) end end) CreateThread(function() while true do local sleep = 1000 local distance = #(Config.Room1Outfit - GetEntityCoords(PlayerPedId())) if InRoom then if distance <= 2 then sleep = 1 QBCore.Functions.DrawText3D(Config.Room1Outfit.x, Config.Room1Outfit.y, Config.Room1Outfit.z, "[E] - Kıyafet Dolabı") if IsControlJustPressed(0, 38) then OpenOutfitMenu() end end end Wait(sleep) end end) -- CreateThread(function() -- while true do -- local sleep = 1000 -- local distance = #(Config.Room2DoorCoords - GetEntityCoords(PlayerPedId())) -- if InRoom then -- if distance <= 2 then -- sleep = 1 -- -- QBCore.Functions.DrawText3D(Config.Room2DoorCoords.x, Config.Room2DoorCoords.y, Config.Room2DoorCoords.z, "[E] - Odadan Çık") -- if IsControlJustPressed(0, 38) then -- ExitRoom() -- end -- end -- end -- Wait(sleep) -- end -- end) CreateThread(function() while true do local sleep = 1000 local distance = #(Config.Room2Stash - GetEntityCoords(PlayerPedId())) if InRoom then if distance <= 2 then sleep = 1 QBCore.Functions.DrawText3D(Config.Room2Stash.x, Config.Room2Stash.y, Config.Room2Stash.z, "[E] - Depo") if IsControlJustPressed(0, 38) then OpenMotelStash() end end end Wait(sleep) end end) CreateThread(function() while true do local sleep = 1000 local distance = #(Config.Room2Outfit - GetEntityCoords(PlayerPedId())) if InRoom then if distance <= 2 then sleep = 1 QBCore.Functions.DrawText3D(Config.Room2Outfit.x, Config.Room2Outfit.y, Config.Room2Outfit.z, "[E] - Kıyafet Dolabı") if IsControlJustPressed(0, 38) then OpenOutfitMenu() end end end Wait(sleep) end end) function ExitRoom() InRoom = false FreezeEntityPosition(PlayerPedId(), true) DoScreenFadeOut(1000) Wait(1000) SetEntityCoords(PlayerPedId(), Config.MotelExitCoords.x, Config.MotelExitCoords.y, Config.MotelExitCoords.z, false) SetEntityHeading(PlayerPedId(), 230.80) FreezeEntityPosition(PlayerPedId(), false) Wait(1000) DoScreenFadeIn(1000) TriggerServerEvent("rafializade-motels:ExitRoom") end