There is a DestroyObject(objectid); bug! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP (
https://sampforum.blast.hk/forumdisplay.php?fid=3)
+--- Forum: Bug Reports (
https://sampforum.blast.hk/forumdisplay.php?fid=20)
+--- Thread: There is a DestroyObject(objectid); bug! (
/showthread.php?tid=251157)
There is a DestroyObject(objectid); bug! -
Donya - 25.04.2011
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
Re: There is a DestroyObject(objectid); bug! -
cyber_punk - 26.04.2011
Quote:
Originally Posted by Donya
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....