Skip to content

Commit

Permalink
Fix for (Error executing native)
Browse files Browse the repository at this point in the history
  • Loading branch information
rxnm committed Jul 27, 2024
1 parent 70b7ba8 commit f96c75b
Showing 1 changed file with 36 additions and 29 deletions.
65 changes: 36 additions & 29 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f96c75b

Please sign in to comment.