25.04.2011, 22:11
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
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
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;
}
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