From f96c75bab7f9c22ca98236482a521c41e559042c Mon Sep 17 00:00:00 2001 From: RyanM Date: Sat, 27 Jul 2024 13:50:10 +0800 Subject: [PATCH] Fix for (Error executing native) --- client.lua | 65 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/client.lua b/client.lua index e92f36f..dc458d5 100644 --- a/client.lua +++ b/client.lua @@ -101,35 +101,42 @@ local function DrawTarget() end local function RaycastCamera(flag, playerCoords) - if not playerPed then playerPed = PlayerPedId() end - if not playerCoords then playerCoords = GetEntityCoords(playerPed) end - - local rayPos, rayDir = ScreenPositionToCameraRay() - local destination = rayPos + 16 * rayDir - local rayHandle = StartShapeTestLosProbe(rayPos.x, rayPos.y, rayPos.z, destination.x, destination.y, destination.z, - flag or -1, playerPed, 4) - - while true do - local result, _, endCoords, _, entityHit = GetShapeTestResult(rayHandle) - - if result ~= 1 then - local distance = playerCoords and #(playerCoords - endCoords) - - if flag == 30 and entityHit then - entityHit = HasEntityClearLosToEntity(entityHit, playerPed, 7) and entityHit - end - - local entityType = entityHit and GetEntityType(entityHit) - - if entityType == 0 and pcall(GetEntityModel, entityHit) then - entityType = 3 - end - - return endCoords, distance, entityHit, entityType or 0 - end - - Wait(0) - end + if not playerPed then playerPed = PlayerPedId() end + if not playerCoords then playerCoords = GetEntityCoords(playerPed) end + + local rayPos, rayDir = ScreenPositionToCameraRay() + local destination = rayPos + 16 * rayDir + local rayHandle = StartShapeTestLosProbe(rayPos.x, rayPos.y, rayPos.z, destination.x, destination.y, destination.z, + flag or -1, playerPed, 4) + + while true do + local result, _, endCoords, _, entityHit = GetShapeTestResult(rayHandle) + + if result ~= 1 then + local distance = playerCoords and #(playerCoords - endCoords) + + -- Add specific condition for ATMs or other entity types + if flag == 30 and entityHit then + -- Assuming 0xAAAA is the model hash for ATMs + local atmModel = 0xAAAA + if GetEntityModel(entityHit) == atmModel then + -- Handle ATMs separately if needed + else + entityHit = HasEntityClearLosToEntity(entityHit, playerPed, 7) and entityHit + end + end + + local entityType = entityHit and GetEntityType(entityHit) + + if entityType == 0 and pcall(GetEntityModel, entityHit) then + entityType = 3 + end + + return endCoords, distance, entityHit, entityType or 0 + end + + Wait(0) + end end exports('RaycastCamera', RaycastCamera)