if Cache.NearbyHouses and #Cache.NearbyHouses > 0 then
for k, v in pairs(Cache.NearbyHouses) do
if not Cache.owned_houses[v.houseid] and not Cache.bought_houses[v.houseid] then
if (not Config.REA or Config.AllowCircle) and Marker(v.data.Entrance.xyz, string.format(Strings["buy_house"], v.data.Label, v.houseid, FormatNumber(v.data.Price))) then
OpenPurchaseMenu(v.houseid)
while #(GetEntityCoords(PlayerPedId()) - v.data.Entrance.xyz) <= 1.1 and ESX.UI.Menu.IsOpen("default", GetCurrentResourceName(), "purchase_house") do
elseif Config.REA and not Config.AllowCircle then
if Marker(v.data.Entrance.xyz, Strings["contact_rea"]:format(v.data.Label, v.houseid)) then
if Config.EnableGarage and (Cache.owned_houses[v.houseid] or exports["loaf_keysystem"]:HasKey("house_" .. v.houseid) and Config.Options.Key.Garage) and v.data.Garage then
local vehicle = GetVehiclePedIsUsing(PlayerPedId())
if DoesEntityExist(vehicle) then
if Marker(v.data.Garage.Exit.xyz + vec3(0.0, 0.0, 0.5), Strings["store_garage"]) then
TriggerEvent('cd_garage:StoreVehicle_Main', 1, false)
if Marker(v.data.Garage.Entrance, Strings["enter_garage"]) then
ESX.UI.Menu.Open( 'default', GetCurrentResourceName(), 'choosegarage', -- Replace the menu name
align = 'center', -- Menu position--top-left
elements = { -- Contains menu elements
{label = ('Go inside'), value = 'ingarage'},
{label = ('Open Menu'), value = 'outgarage'}
function(data, menu) -- This part contains the code that executes when you press enter
if data.current.value == 'ingarage' then
TriggerEvent('cd_garage:PropertyGarage', 'inside')
FreezeEntityPosition(GetPlayerPed(-1),false)
elseif data.current.value == 'outgarage' then
TriggerEvent('cd_garage:PropertyGarage', 'quick')
FreezeEntityPosition(GetPlayerPed(-1),false)
function(data, menu) -- This part contains the code that executes when the return key is pressed.
menu.close() -- Close the menu
FreezeEntityPosition(GetPlayerPed(-1),false)
Marker(v.data.Entrance.xyz)
if #(v.data.Entrance.xyz - GetEntityCoords(PlayerPedId())) <= 2.0 then
if Cache.owned_houses[v.houseid] then
suffix = Strings["press_manage"]
if IsControlJustReleased(0, ((Config.Options and Config.Options.SecondaryAction) or (47))) then
elseif Cache.IsPolice then
suffix = Strings["breach_door"]
elseif Config.LockPicking and Config.LockPicking.Enabled then
suffix = Strings["lockpick_door"]
if Cache.unlocked_doors[v.houseid] then
DrawTxt3D(v.data.Entrance.xyz, Strings["unlocked"] .. " (" .. v.houseid .. ")", true, true)
if #(v.data.Entrance.xyz - GetEntityCoords(PlayerPedId())) <= 1.0 then
if suffix == Strings["press_manage"] then
HelpText(Strings["enter"] .. suffix, true)
HelpText(Strings["enter"], true)
if IsControlJustReleased(0, ((Config.Options and Config.Options.MainAction) or (51))) then
DrawTxt3D(v.data.Entrance.xyz, Strings["locked"] .. " (" .. v.houseid .. ")" .. suffix, true, true)
if Cache.IsPolice and suffix == Strings["breach_door"] and IsControlJustReleased(0, ((Config.Options and Config.Options.SecondaryAction) or (47))) then
TriggerServerEvent("loaf_housing:breachDoor", v.houseid)
elseif IsControlJustReleased(0, ((Config.Options and Config.Options.SecondaryAction) or (47))) and suffix == Strings["lockpick_door"] then
local success = LockPick(tonumber(v.houseid))
ClearPedTasks(PlayerPedId())
TriggerServerEvent("loaf_housing:successfulLockpick", v.houseid)
while #(GetEntityCoords(PlayerPedId()) - Config.IKEA.EnterIKEA.xyz) <= 25.0 do
if Marker(Config.IKEA.EnterIKEA.xyz, Strings["enter_ikea"]) then
elseif #(GetEntityCoords(PlayerPedId()) - Config.IKEA.EnterIKEA.xyz) <= 1.0 and IsControlJustReleased(0, ((Config.Options and Config.Options.SecondaryAction) or (47))) then