@@ -255,17 +255,26 @@ CreateThread(function()
255255
256256 if isPauseMenuState == 0 and isNuiFocused ~= 1 then
257257 if not closestEntity then
258- local playerPosition = GetEntityCoords (playerPed )
259258 local model = 0
260259 local entityType = 0
260+ local playerPosition = GetEntityCoords (playerPed )
261261 -- #TODO: Give onPosition priority?!
262262 -- It's going to lower resource usage, BUT if we have two colliding menus, we might not be able to detect them.
263263 -- reason: when the player is inside the `entity detector`, we won't be able to use rayCast to detect other menus.
264264
265265 local hitPosition , playerDistance , entity
266- if closestZoneId == nil and ( not StateManager .get (" disableRayCast" ) or isInVehicle ~= 1 ) then
266+ if not StateManager .get (" disableRayCast" ) and isInVehicle == false then
267267 hitPosition , entity , playerDistance = Util .rayCast (10 , playerPed )
268268
269+ if hitPosition and not StateManager .get (" disableZoneRayCast" ) then
270+ for key , value in pairs (Container .zones ) do
271+ if value .tracker == " hit" and value :isPointInside (hitPosition ) then
272+ closestZoneId = value .name
273+ break
274+ end
275+ end
276+ end
277+
269278 if entity then
270279 entityType = GetEntityType (entity )
271280 if entityType ~= 0 then
@@ -313,8 +322,10 @@ end)
313322
314323AddEventHandler (" interactionMenu:zoneTracker" , function (zone_name , state )
315324 if zone_name and state then
325+ StateManager .set (" disableZoneRayCast" , true )
316326 closestZoneId = zone_name
317327 else
328+ StateManager .set (" disableZoneRayCast" , false )
318329 closestZoneId = nil
319330 end
320331end )
@@ -489,22 +500,33 @@ function Render.onZone(currentMenuId)
489500 local rotation = data .rotation
490501 if not position then return end
491502
503+ local validateSlow
504+ if data .tracker == " hit" then
505+ validateSlow = function ()
506+ local hitPosition , entity , playerDistance = Util .rayCast (10 , PlayerPedId ())
507+ return Container .zones [currentMenuId ]:isPointInside (hitPosition )
508+ end
509+ end
510+
492511 Render .generic (data , metadata , {
493512 onEnter = function ()
494513 StateManager .set (' disableRayCast' , true )
495514 scaleform .setForwardVectorLock (false )
496515 scaleform .setPosition (position )
497516
498517 if rotation then
499- scaleform .setRotation (rotation )
500518 scaleform .set3d (true )
519+ scaleform .setRotation (rotation )
501520 scaleform .setScale (data .scale or 1 )
521+ else
522+ scaleform .set3d (false )
502523 end
503524 return true
504525 end ,
505526 validate = function ()
506527 return StateManager .get (' id' ) == currentMenuId
507528 end ,
529+ validateSlow = validateSlow ,
508530 onExit = function ()
509531 StateManager .set (' disableRayCast' , false )
510532 end
0 commit comments