2020-12-19, 02:54 AM
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:
- 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;
}