DestroyDynamicObject destroying the wrong object
#1

And I have no idea why.

PHP Code:
// top of the gamemode
new obTown[300];
new 
obTemp;
// GameModeInit
obTown[0] = CreateDynamicObject(23322330.53412392.489511.74540.00000.00000.0000);
obTown[1] = CreateDynamicObject(81682293.59832370.78958.16950.00000.000016.6998); // and so on...
// somewhere else in the code 
if(IsValidDynamicObject(obTemp)) DestroyDynamicObject(obTemp); // HERE IS THE PROBLEM 
Simple enough, should work, right?
Well, for god knows what reason the last line deletes obTown[0] object, even thought I've added IsValidDynamicObject(obTemp), and obTemp wasn't created yet. So why on earth does the last code delete obTown[0]?
Primo, the code after IsValidDynamicObject(obTemp) should not execute. Secundo, it should not even a random object when it cannot find obTemp.
Am I missing something here?
Reply
#2

Try this, you have defined "obTemp" only, so, it will delete the first value (which is 0).

try adding a loop to it by doing this:

PHP Code:
for(new 0sizeof(obTemp), i++)
{
    if(
IsValidDynamicObject(obTemp[i])) DestroyDynamicObject(obTemp[i]);

Reply
#3

But obTemp is not an array, it is a single object.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)