Skip to content

Commit

Permalink
Raid Apartment
Browse files Browse the repository at this point in the history
  • Loading branch information
ImXirvin committed Jul 22, 2023
1 parent 7193f9b commit 6646879
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 4 deletions.
32 changes: 31 additions & 1 deletion client/apartment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ function Apartment:RegisterPropertyEntrance()
self:GetMenuForAll()
end

local function seeAllToRaid()
self:GetMenuForAllToRaid()
end

local size = vector3(door.length, door.width, 3.0)
local heading = door.h

Framework[Config.Target].AddApartmentEntrance(door, size, heading, self.apartmentData.label, enterApartment, seeAll, targetName)
Framework[Config.Target].AddApartmentEntrance(door, size, heading, self.apartmentData.label, enterApartment, seeAll, seeAllToRaid, targetName)
end

function Apartment:EnterApartment()
Expand Down Expand Up @@ -76,6 +80,32 @@ function Apartment:GetMenuForAll()
lib.showContext(id)
end

function Apartment:GetMenuForAllToRaid()
if next(self.apartments) == nil then
Framework[Config.Notify].Notify("There are no apartments here.", "error")
return
end

local id = "apartments-" .. self.apartmentData.label
local menu = {
id = id,
title = "Apartments To Raid",
options = {}
}

for propertyId, _ in pairs(self.apartments) do
table.insert(menu.options,{
title = "Raid " .. self.apartmentData.label .. " " .. propertyId,
onSelect = function()
TriggerServerEvent("ps-housing:server:raidProperty", propertyId)
end,
})
end

lib.registerContext(menu)
lib.showContext(id)
end

function Apartment:CreateBlip(hasProperty)
self:DeleteBlip()

Expand Down
32 changes: 29 additions & 3 deletions shared/framework.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Framework.qb = {
return targetName
end,

AddApartmentEntrance = function(coords, size, heading, apartment, enter, seeAll, targetName)
AddApartmentEntrance = function(coords, size, heading, apartment, enter, seeAll, seeAllToRaid, targetName)
exports['qb-target']:AddBoxZone(targetName, vector3(coords.x, coords.y, coords.z), size.x, size.y, {
name = targetName,
heading = heading,
Expand All @@ -130,7 +130,20 @@ Framework.qb = {
{
label = "See all apartments",
action = seeAll,
}
},
{
label = "Raid Apartment",
action = seeAllToRaid,
canInteract = function()
local PlayerData = QBCore.Functions.GetPlayerData()
local job = PlayerData.job
local jobName = job.name
local gradeAllowed = tonumber(job.grade.level) >= Config.MinGradeToRaid
local onDuty = job.onduty

return jobName == Config.PoliceJobName and gradeAllowed and onDuty
end,
},
}
})
end,
Expand Down Expand Up @@ -281,7 +294,7 @@ Framework.ox = {
return handler
end,

AddApartmentEntrance = function (coords, size, heading, apartment, enter, seeAll, _)
AddApartmentEntrance = function (coords, size, heading, apartment, enter, seeAll, seeAllToRaid, _)
local handler = exports.ox_target:addBoxZone({
coords = vector3(coords.x, coords.y, coords.z),
size = vector3(size.y, size.x, size.z),
Expand All @@ -300,6 +313,19 @@ Framework.ox = {
label = "See all apartments",
onSelect = seeAll,
},
{
label = "Raid Apartment",
onSelect = seeAllToRaid,
canInteract = function()
local PlayerData = QBCore.Functions.GetPlayerData()
local job = PlayerData.job
local jobName = job.name
local gradeAllowed = tonumber(job.grade.level) >= Config.MinGradeToRaid
local onDuty = job.onduty

return jobName == "police" and onDuty and gradeAllowed
end,
},
},
})

Expand Down

0 comments on commit 6646879

Please sign in to comment.