Skip to content

Entity state is inaccessible on entity removal #3081

Open
@bianchim

Description

@bianchim

What happened?

Since artifact 12160 and the changes in DeleteVehicle, it's impossible to get a vehicle state before its complete deletion.

On older artifacts you could still for a bit of time get an entity state on deletion, in order to have some actions on vehicle deletion for exemple :

AddEventHandler('entityRemoved', function(entity)
    if DoesEntityExist(vehicle.entity) then
        local State = Entity(EntityId).state
        -- do some stuff ...
    end
end)

Since artifact 1260, the DoesEntityExist always return false in this event, and the state is empty.

For scripting doing impound and garage functionality, this is a must have to be able to handle vehicle deletion and persistence correctly.

We would either need an event EntityRemoving similar to creating, or still get the old behavior on older artifacts.

Expected result

Getting access to vehicle data on deletion

Reproduction steps

  1. Add an event handler on 'entityRemoved', and try to get the vehicle state using Entity(EntityId).state in the function's body
  2. Remove an entity using the DeleteVehicle native
  3. the state is not accessible and the entity is indicated as removed by the DoesEntityExist native immediately, instead of having a grace period.

Importancy

Slight inconvenience

Area(s)

FiveM, ScRT: Lua

Specific version(s)

FiveM 12160 and newer

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ScRT: LuaIssues/PRs related to the Lua scripting runtimebugtriageNeeds a preliminary assessment to determine the urgency and required action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions