There is a DestroyObject(objectid); bug!
#1

someone posted a while ago that destroyobject(objectid); does not reset the objectid to INVALID_OBJECT_ID, well its true and its in even more dept.

I confirmed that bug and found another bug while in it.

try a code like this

pawn Code:
forward Destroy_Object(objectid);
public Destroy_Object(objectid) return printf("Objectid %d Destroyed",objectid), IsValidObject(objectid) == 1 ? DestroyObject(objectid) : 1;
public OnPlayerSpawn(playerid)
{
    new objectid;
    objectid = CreateObject(...);
    DestroyObject(objectid);
    SetTimerEx("Destroy_Object", 10000, false, "i", objectid);
    return 1;
}
ok it works fine for now right?
but see i am destroying the object again in a timer, so the objectid is still 1
let someone spawn again! within 10 seconds, and instead it wouldn't destroy object id 2, it would destroy objectid 1

even with IsValidObject(objectid); this bug still happens!

simple explanation: because destroyobject isn't resetting the variable, its causing other bugs.
Example: i am create missiles, when i fire missiles, so when i destroy the object, and do some other checks, it destroys the wrong objectid
Reply
#2

Quote:
Originally Posted by Donya
View Post
someone posted a while ago that destroyobject(objectid); does not reset the objectid to INVALID_OBJECT_ID, well its true and its in even more dept.

I confirmed that bug and found another bug while in it.

try a code like this

pawn Code:
forward Destroy_Object(objectid);
public Destroy_Object(objectid) return printf("Objectid %d Destroyed",objectid), IsValidObject(objectid) == 1 ? DestroyObject(objectid) : 1;
public OnPlayerSpawn(playerid)
{
    new objectid;
    objectid = CreateObject(...);
    DestroyObject(objectid);
    SetTimerEx("Destroy_Object", 10000, false, "i", objectid);
    return 1;
}
ok it works fine for now right?
but see i am destroying the object again in a timer, so the objectid is still 1
let someone spawn again! within 10 seconds, and instead it wouldn't destroy object id 2, it would destroy objectid 1

even with IsValidObject(objectid); this bug still happens!

simple explanation: because destroyobject isn't resetting the variable, its causing other bugs.
Example: i am create missiles, when i fire missiles, so when i destroy the object, and do some other checks, it destroys the wrong objectid
To be honest none of the Destroy functions reset any of the variables although I always thought they should do it internally that is simply not the case the scripters are the ones to clear/reset all variables. Just try this with TextDrawDestroy, DestroyPickup etc....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)