Destrying Object ?
#1

I have question about DestroyObject, I have many objects, but I want to destroy them all is this possible with single function or I need to define every object ? OBJ1 = CreateObject(...) ... OBJ2 ... and than DestroyObject(OBJ1) .. ?
Is there something to destroy multiply objects ? cut here are my current objects (I'm not making server, just learning to script.. )

pawn Код:
CreateObject(1271,1473.3000488,-1803.1999512,4084.8999023,0.0000000,0.0000000,0.0000000); //object(gunbox) (1)
                CreateObject(1271,1474.3000488,-1804.2993164,4084.9628906,0.0000000,0.0000000,0.0000000); //object(gunbox) (2)
                CreateObject(1271,1475.5000000,-1808.0999756,4085.0000000,0.0000000,0.0000000,333.7500000); //object(gunbox) (3)
                CreateObject(1271,1474.3000488,-1804.9000244,4085.6000977,5.7499390,359.7487183,1.0251770); //object(gunbox) (4)
                CreateObject(1271,1474.5000000,-1805.3000488,4084.8999023,0.0000000,0.0000000,306.0000000); //object(gunbox) (5)
                CreateObject(1271,1474.5999756,-1807.1999512,4085.0000000,0.0000000,0.0000000,333.7481689); //object(gunbox) (6)
                CreateObject(1271,1475.1015625,-1806.2094727,4084.9726562,0.0000000,0.0000000,333.7481689); //object(gunbox) (7)
                CreateObject(1271,1474.8000488,-1806.6999512,4085.6000977,0.0000000,0.0000000,333.7481689); //object(gunbox) (8)
                CreateObject(1517,1475.5999756,-1808.3000488,4085.5000000,0.0000000,0.0000000,0.0000000); //object(dyn_wine_break) (1)
                CreateObject(1517,1475.1999512,-1808.1999512,4085.5000000,0.0000000,0.0000000,0.0000000); //object(dyn_wine_break) (2)
                CreateObject(1517,1474.6999512,-1807.5999756,4085.5000000,0.0000000,0.0000000,0.0000000); //object(dyn_wine_break) (3)
                CreateObject(1517,1474.8000488,-1806.6999512,4086.1000977,0.0000000,0.0000000,0.0000000); //object(dyn_wine_break) (4)
                CreateObject(1517,1475.1999512,-1806.0999756,4085.5000000,0.0000000,0.0000000,0.0000000); //object(dyn_wine_break) (5)
                CreateObject(1517,1474.5999756,-1805.4000244,4085.3999023,0.0000000,0.0000000,0.0000000); //object(dyn_wine_break) (6)
                CreateObject(1517,1474.1999512,-1805.0999756,4086.1000977,0.0000000,0.0000000,0.0000000); //object(dyn_wine_break) (8)
                CreateObject(1517,1474.1999512,-1804.3000488,4085.5000000,0.0000000,0.0000000,0.0000000); //object(dyn_wine_break) (9)
                CreateObject(1517,1473.1999512,-1803.4000244,4085.3999023,0.0000000,0.0000000,0.0000000); //object(dyn_wine_break) (10)
                CreateObject(1517,1473.5000000,-1802.9000244,4085.3999023,0.0000000,0.0000000,0.0000000); //object(dyn_wine_break) (11)
                CreateObject(1517,1473.6999512,-1803.5000000,4084.8000488,0.0000000,0.0000000,0.0000000); //object(dyn_wine_break) (12)
Reply
#2

You must define the objects in order to delete them, so you can do something like this
pawn Код:
new Objects[50]; //The 50 stands for amount of objects you are going to define so you can change this.

Objects[1] = CreateObject(blabla..
Objects[2] = CreateObject(blabla..
//And so on

//Now loop through the objects
for(new x; x < 50; x++)
    {
    DestroyObject(Objects[x]);
    return 1;
    }
Reply
#3

Thank you very much I will try it
Reply
#4

There is another simple way

new o_mapname[2];

o_mapname[0] = FIRST CREATE OBJECT
Objects..
Objects..
Objects..
Objects..
Objects..

o_mapname[1] = LAST OBJECT

//Now loop through the objects
for(new x = o_mapname[0]; x < o_mapname[1]; x++)
{
DestroyObject(x);
return 1;
}
Reply
#5

Quote:
Originally Posted by Rapgangsta
Посмотреть сообщение
There is another simple way
Thats a nice one, but not 100% safe if you create the objects in runtime. Within one function in general all created object ids will be counted in a row. You just get problems if you deleted some object in the "middle" of object ids, you get stuff like that:

Код:
id       map
1 old
2 old 
3 old
4 new
5 old
6 new
7 new
So you might encounter some "old" objects if you just store the start and end. Your code would also delete id 5, even it doesnt belong to the map. You could use linked lists to minimze memory usage without getting this problem, but they arent available without plugins / tricky includes.
Reply
#6

Okay I've got a problem with those codes, I tried both codes but they don't want to work :S
Here is what I tried
pawn Код:
if(listitem == 0 && MR == 1)
    {
        CreateObject(1517,1475.0999756,-1794.0000000,4086.0000000,0.0000000,0.0000000,0.0000000); //object(dyn_wine_break) (28)
        for(new x = o_mapname[0]; x < o_mapname[1]; x++)
        {
            DestroyObject(x);
            return 1;
        }
So when I choose something at menu, I want those objects destroyed...

And here are some objects for example
pawn Код:
o_mapname[0] = CreateObject(1271,1473.3000488,-1803.1999512,4084.8999023,0.0000000,0.0000000,0.0000000); //object(gunbox) (1)
                CreateObject(1271,1474.3000488,-1804.2993164,4084.9628906,0.0000000,0.0000000,0.0000000); //object(gunbox) (2)
                CreateObject(1271,1475.5000000,-1808.0999756,4085.0000000,0.0000000,0.0000000,333.7500000); //object(gunbox) (3)
                CreateObject(1271,1474.3000488,-1804.9000244,4085.6000977,5.7499390,359.7487183,1.0251770); //object(gunbox) (4)
                CreateObject(1271,1474.5000000,-1805.3000488,4084.8999023,0.0000000,0.0000000,306.0000000); //object(gunbox) (5)
                CreateObject(1271,1474.5999756,-1807.1999512,4085.0000000,0.0000000,0.0000000,333.7481689); //object(gunbox) (6)
                CreateObject(1271,1475.1015625,-1806.2094727,4084.9726562,0.0000000,0.0000000,333.7481689); //object(gunbox) (7)
                CreateObject(1271,1474.8000488,-1806.6999512,4085.6000977,0.0000000,0.0000000,333.7481689); //object(gunbox) (8)
                CreateObject(1517,1475.5999756,-1808.3000488,4085.5000000,0.0000000,0.0000000,0.0000000); //object(dyn_wine_break) (1)
                o_mapname[1] = CreateObject(1517,1475.1999512,-1808.1999512,4085.5000000,0.0000000,0.0000000,0.0000000); //object(dyn_wine_break) (2)
I putted this above everything... at start of my script
pawn Код:
new o_mapname[2];
What have I done wrong ? :/
Reply
#7

Anyone please ? :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)