Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetEntityArchetypeName invoke error on ground #2840

Open
Mathu-lmn opened this issue Oct 4, 2024 · 2 comments
Open

GetEntityArchetypeName invoke error on ground #2840

Mathu-lmn opened this issue Oct 4, 2024 · 2 comments
Labels
bug ScRT: Lua Issues/PRs related to the Lua scripting runtime triage Needs a preliminary assessment to determine the urgency and required action

Comments

@Mathu-lmn
Copy link
Contributor

What happened?

When trying to start an StartExpensiveSynchronousShapeTestLosProbe, if the returned entity is not a ped, a vehicle or a game object, the GetEntityArchetype function will error

Expected result

Return the correct entity archetype or an empty string

Reproduction steps

Execute the following "bug" command while on the ground

RegisterCommand("bug", function()
    local playerPed = PlayerPedId()
    local coordA = GetEntityCoords(playerPed)
    local coordB = GetOffsetFromEntityInWorldCoords(playerPed, 0.0, 0.0, -5.0)

    local rayHandle = StartExpensiveSynchronousShapeTestLosProbe(coordA.x, coordA.y, coordA.z, coordB.x, coordB.y, coordB.z, -1, PlayerPedId(), 0)
    local _, hit, _, _, _, entity = GetShapeTestResultIncludingMaterial(rayHandle)

    if hit == 1 or hit == true then
		print(entity)
		print(GetEntityArchetypeName(entity))
    end
end)

Importancy

Slight inconvenience

Area(s)

FiveM, Natives, ScRT: Lua

Specific version(s)

server 10191 - client canary b3095

Additional information

No response

@Mathu-lmn Mathu-lmn added bug triage Needs a preliminary assessment to determine the urgency and required action labels Oct 4, 2024
@github-actions github-actions bot added the ScRT: Lua Issues/PRs related to the Lua scripting runtime label Oct 4, 2024
@manzarek123
Copy link
Contributor

Same for GetEntityModel if I rembember well
The following should help you filter "valid" entities

if DoesEntityExist(entity) and DoesEntityHaveDrawable(entity) then
  -- rest of your code
end

@Mathu-lmn
Copy link
Contributor Author

Hi thanks for the suggestion I didn't think about checking for drawables.
I do think however that we should be able to get the name of the entity even if it has no drawable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ScRT: Lua Issues/PRs related to the Lua scripting runtime triage Needs a preliminary assessment to determine the urgency and required action
Projects
None yet
Development

No branches or pull requests

2 participants