• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Disappearance of dynamic objects
#5
I've faced this error a few times, avoiding it comes down to following two key practices:



- Always check if a dynamic object is valid with IsValidDynamicObject(objectid) before destroying it.

- When destroying an object, ALWAYS set the variable which held it to INVALID_OBJECT_ID to avoid collisions with newly created objects in the future.



This helper should do both:



Code:
stock DestroyDynObj(&objectid) {

    new bool:success = false;

    if (IsValidDynamicObject(objectid) {

        DestroyDynamicObject(objectid);

        success = true;

    }

    objectid = INVALID_OBJECT_ID;

    return success;

}
  Reply


Messages In This Thread
Disappearance of dynamic objects - by Radical - 2020-12-15, 11:07 PM
RE: Disappearance of dynamic objects - by Pinch - 2020-12-15, 11:24 PM
RE: Disappearance of dynamic objects - by DaZzY - 2020-12-16, 04:25 PM
RE: Disappearance of dynamic objects - by Radical - 2020-12-17, 12:15 PM
RE: Disappearance of dynamic objects - by Markski - 2020-12-19, 02:54 AM

Forum Jump: