Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
fix(client): support objects with invalid entity type
Browse files Browse the repository at this point in the history
Some entities will return an entity type of 0 ("no entity"), despite clearly
being an entity. Calling GetEntityModel either returns a model, or throws
a native invocation error.
Use a protected call for GetEntityModel and treat anything with a model
as an object.

Notably fixes interaction with (most?) trees, who knows what else.
  • Loading branch information
thelindat committed Aug 4, 2022
1 parent 0dacab4 commit 2378182
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ local function RaycastCamera(flag, playerCoords)
entityHit = HasEntityClearLosToEntity(entityHit, playerPed, 7) and entityHit
end

return endCoords, distance, entityHit, entityHit and GetEntityType(entityHit) or 0
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)
Expand Down

0 comments on commit 2378182

Please sign in to comment.