Skip to content

Commit

Permalink
feat: add PolyZone warning
Browse files Browse the repository at this point in the history
  • Loading branch information
swkeep committed Feb 10, 2024
1 parent e71786a commit 86f20c4
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions interactionMenu/lua/client/menuContainer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,14 @@ local GetPlayerServerId = GetPlayerServerId
local NetworkGetPlayerIndexFromPed = NetworkGetPlayerIndexFromPed
local SpatialHashGrid = Util.SpatialHashGrid
local grid = SpatialHashGrid:new('position', 100)
local zone_grid = SpatialHashGrid:new('zone', 100)
local StateManager = Util.StateManager()
local PersistentData = Util.PersistentData()
local previous_daytime = false

-- enum: used in difference between OBJECTs, PEDs, VEHICLEs
EntityTypes = Util.ENUM {
'PED',
'VEHICLE',
'OBJECT'
}
local set = {
"peds",
"vehicles",
"objects"
}
local set = { "peds", "vehicles", "objects" }
EntityTypes = Util.ENUM { 'PED', 'VEHICLE', 'OBJECT' }

-- class: PersistentData
-- managing menus
Expand All @@ -60,6 +53,10 @@ Container = {
}
}

local function canCreateZone()
return GetResourceState('PolyZone') == 'started'
end

--- Build interaction table for named interactions (canInteract, onSeen, onExit)
---@param data table 'raw menu data'
---@param interactions table 'interactions reference table to add interactions into it'
Expand Down Expand Up @@ -222,8 +219,6 @@ local function transformJobData(data)
end
end

local zone_grid = SpatialHashGrid:new('zone', 100)

local function AddBoxZone(o)
local z = BoxZone:Create(vec3(o.position.x, o.position.y, o.position.z), o.length or 1.0, o.width or 1.0, {
name = o.name,
Expand Down Expand Up @@ -313,18 +308,22 @@ function Container.create(t)
end
end
elseif t.zone and t.position then
instance.type = 'zone'
instance.position = {
x = t.position.x,
y = t.position.y,
z = t.position.z,
id = id
}
if canCreateZone() then
instance.type = 'zone'
instance.position = {
x = t.position.x,
y = t.position.y,
z = t.position.z,
id = id
}

instance.rotation = t.rotation
instance.zone = t.zone
Container.zones[id] = AddBoxZone(t.zone)
zone_grid:insert(instance.position)
instance.rotation = t.rotation
instance.zone = t.zone
Container.zones[id] = AddBoxZone(t.zone)
zone_grid:insert(instance.position)
else
warn('Could not find `PolyZone`. Make sure it is started before interactionMenu.')
end
end

buildOption(t, instance)
Expand Down

0 comments on commit 86f20c4

Please sign in to comment.