altmp / altv-issues

Issues and roadmap for alt:V project
92 stars 17 forks source link

[Server-side] After destroy any server object OnColShape event will never be triggered #2253

Open M1raclee opened 4 months ago

M1raclee commented 4 months ago

Description of the problem

When you have colshape and object on server-side and destroy object -> OnColShape event breaks and not triggers ever

Code:

        Alt.OnColShape += (colshape, targetEntity, state) =>
        {
            Alt.Log($"Colshape: {colshape.Id}, {targetEntity.Id}, {state}");
        };
        Alt.OnConsoleCommand += (name, args) =>
        {
            if (name == "destroy")
            {
                _obj?.Destroy();
                Alt.Log("Obj destroyed");
            }
        };

        _obj = Alt.CreateObject(Alt.Hash("v_ret_ta_box"), new Position(10, 10, 74.5f), new Rotation(0, 0, 0));
        Alt.CreateColShapeSphere(new Position(10, 10, 75), 5);

Reproduction steps

  1. Subscribe to OnColShape event
  2. Create any server-side object
  3. Create any server-side colshape (for example, sphere)
  4. Enter/exit to colshape zone and ensure that OnColShape works fine (check log message)
  5. Destroy server-side object (for example, with server command "destroy")
  6. Enter to colshape again => OnColShape will be not triggered, you won't see log message

Expected behaviour

OnColShape works fine after destroy server-side objects

Additional context

It was working fine a couple weeks ago, but now it's broken. Tested with C# module

Operating system

Windows 10

Version

client/server: 16.0.0-dev.289, NuGet: 16.0.0-dev.30

Crashdump ID

No response

Confirmation of issue's presence

litolax commented 3 months ago

Reproduced with this code on the latest 16.0.0-dev.290 (dev)

alt.on("entityEnterColshape", (colshape, entity) => {
    console.log('enter: ', entity, colshape);
})

globalThis.col = new alt.ColshapeSphere(player.pos.x, player.pos.y, player.pos.z, 20);

globalThis.obj = new alt.Object('v_ret_ta_box', player.pos, player.rot);

globalThis.obj.destroy();