SA-MP Forums Archive
help with DestroyObject - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help with DestroyObject (/showthread.php?tid=433124)



help with DestroyObject - dash5487 - 25.04.2013

hi
i have many objects and i put it in
PHP код:
CreateMyCustom() {
        
CreateObject(2942,-2095.8000488,463.2000122,34.7999992,0.0000000,0.0000000,270.0000000); //object(kmb_atm1) (12)
        
CreateObject(10948,-2095.8999023,467.6000061,96.5000000,0.0000000,0.0000000,0.0000000); //object(skyscrapper_sfs) (1)
        
CreateObject(2634,2310.3000488,-0.1000000,27.2999992,0.0000000,0.0000000,180.0000000); //object(ab_vaultdoor) (1)
        
CreateObject(18553,2311.3000488,-3.7000000,28.2999992,0.0000000,0.0000000,0.0000000); //object(count_ammundoor) (1)
        
CreateObject(18553,2311.1999512,0.2000000,30.0000000,0.0000000,0.0000000,0.0000000); //object(count_ammundoor) (2)
        
CreateObject(18553,2311.3000488,-4.8000002,28.2999992,0.0000000,0.0000000,0.0000000); //object(count_ammundoor) (3)
        
CreateObject(18553,2309.3999023,-6.6999998,28.2999992,0.0000000,0.0000000,90.0000000); //object(count_ammundoor) (4)
        
CreateObject(18553,2306.1999512,-6.8000002,28.2999992,0.0000000,0.0000000,90.0000000); //object(count_ammundoor) (5)
        
CreateObject(2332,2305.6999512,-4.5999999,27.1000004,0.0000000,0.0000000,90.0000000); //object(kev_safe) (2)
        
CreateObject(1829,2306.0996094,-4.5996094,26.2000008,0.0000000,0.0000000,90.0000000); //object(man_safenew) (2)
        
CreateObject(1616,2311.3486328,-4.7900391,29.6957912,0.0000000,0.0000000,0.0000000); //object(nt_securecam1_01) (1)
        
CreateObject(5821,-2050.6000977,-1403.0999756,104.0999985,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (1)
        
CreateObject(5821,-2051.1999512,-1389.8000488,94.5999985,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (2)
        
CreateObject(5821,-2051.6000977,-1376.3000488,85.1999969,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (3)
        
CreateObject(5821,-2051.8999023,-1362.6999512,75.1999969,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (4)
        
CreateObject(5821,-2052.8999023,-1350.0000000,65.4000015,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (5)
        
CreateObject(5821,-2053.6000977,-1336.5999756,55.5999985,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (6)
        
CreateObject(5821,-2053.8000488,-1322.4000244,45.0999985,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (7)
        
CreateObject(5821,-2054.1999512,-1307.9000244,34.5999985,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (8)
        
CreateObject(5821,-2054.5000000,-1293.5000000,24.3999996,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (9)
        
CreateObject(5821,-2062.1999512,-1279.5000000,4.4000001,0.0000000,0.0000000,172.0000000); //object(odrampbit03) (10)
        
CreateObject(3406,-2058.1000977,-1268.0999756,6.4000001,0.0000000,0.0000000,0.0000000); //object(cxref_woodjetty) (1)
        
CreateObject(5821,-2055.1992188,-1279.3994141,13.6000004,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (11)
        
CreateObject(3406,-2064.1000977,-1270.9000244,6.4000001,0.0000000,0.0000000,86.0000000); //object(cxref_woodjetty) (2)

and in a timer i want to destroy all of those objects
it will created but not destroy

PHP код:
public DeleteCustom()
{
    
DestroyObject(CreateMyCustom()); // i also used  ETC : DestroyObject(3406) but it wont destroy the object




Re: help with DestroyObject - iJumbo - 25.04.2013

something like

pawn Код:
new MyObjectArray[24];

Createblabla {
    MyObjectArray[0] = CreateObject(2942,-2095.8000488,463.2000122,34.7999992,0.0000000,0.0000000,270.0000000); //object(kmb_atm1) (12)
    MyObjectArray[1] = CreateObject(10948,-2095.8999023,467.6000061,96.5000000,0.0000000,0.0000000,0.0000000); //object(skyscrapper_sfs) (1)
    MyObjectArray[2] = CreateObject(2634,2310.3000488,-0.1000000,27.2999992,0.0000000,0.0000000,180.0000000); //object(ab_vaultdoor) (1)
    MyObjectArray[3] = CreateObject(18553,2311.3000488,-3.7000000,28.2999992,0.0000000,0.0000000,0.0000000); //object(count_ammundoor) (1)
    MyObjectArray[4] = CreateObject(18553,2311.1999512,0.2000000,30.0000000,0.0000000,0.0000000,0.0000000); //object(count_ammundoor) (2)
    MyObjectArray[5] = CreateObject(18553,2311.3000488,-4.8000002,28.2999992,0.0000000,0.0000000,0.0000000); //object(count_ammundoor) (3)
    MyObjectArray[6] = CreateObject(18553,2309.3999023,-6.6999998,28.2999992,0.0000000,0.0000000,90.0000000); //object(count_ammundoor) (4)
    MyObjectArray[7] = CreateObject(18553,2306.1999512,-6.8000002,28.2999992,0.0000000,0.0000000,90.0000000); //object(count_ammundoor) (5)
    MyObjectArray[8] = CreateObject(2332,2305.6999512,-4.5999999,27.1000004,0.0000000,0.0000000,90.0000000); //object(kev_safe) (2)
    MyObjectArray[9] = CreateObject(1829,2306.0996094,-4.5996094,26.2000008,0.0000000,0.0000000,90.0000000); //object(man_safenew) (2)
    MyObjectArray[10] = CreateObject(1616,2311.3486328,-4.7900391,29.6957912,0.0000000,0.0000000,0.0000000); //object(nt_securecam1_01) (1)
    MyObjectArray[11] = CreateObject(5821,-2050.6000977,-1403.0999756,104.0999985,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (1)
    MyObjectArray[12] = CreateObject(5821,-2051.1999512,-1389.8000488,94.5999985,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (2)
    MyObjectArray[13] = CreateObject(5821,-2051.6000977,-1376.3000488,85.1999969,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (3)
    MyObjectArray[14] = CreateObject(5821,-2051.8999023,-1362.6999512,75.1999969,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (4)
    MyObjectArray[15] = CreateObject(5821,-2052.8999023,-1350.0000000,65.4000015,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (5)
    MyObjectArray[16] = CreateObject(5821,-2053.6000977,-1336.5999756,55.5999985,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (6)
    MyObjectArray[17] = CreateObject(5821,-2053.8000488,-1322.4000244,45.0999985,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (7)
    MyObjectArray[18] = CreateObject(5821,-2054.1999512,-1307.9000244,34.5999985,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (8)
    MyObjectArray[19] = CreateObject(5821,-2054.5000000,-1293.5000000,24.3999996,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (9)
    MyObjectArray[20] = CreateObject(5821,-2062.1999512,-1279.5000000,4.4000001,0.0000000,0.0000000,172.0000000); //object(odrampbit03) (10)
    MyObjectArray[21] = CreateObject(3406,-2058.1000977,-1268.0999756,6.4000001,0.0000000,0.0000000,0.0000000); //object(cxref_woodjetty) (1)
    MyObjectArray[22] = CreateObject(5821,-2055.1992188,-1279.3994141,13.6000004,0.0000000,0.0000000,0.0000000); //object(odrampbit03) (11)
    MyObjectArray[23] = CreateObject(3406,-2064.1000977,-1270.9000244,6.4000001,0.0000000,0.0000000,86.0000000); //object(cxref_woodjetty) (2)
}

public DeleteCustom()
{
    for(new objectid = 0; objectid != sizeof(MyObjectArray); objectid++) {
        DestroyObject(MyObjectArray[objectid]);
    }
}



Re: help with DestroyObject - Pottus - 25.04.2013

@ijumbo But that isn't a very nice way how about this

Try this you can decrease MAX_LOADER_OBJECTS if your not going to ever get near 1000 you could also change CreateObject() and DeleteObject() to streamer counterparts cheers.

pawn Код:
#define             MAX_LOADER_OBJECTS              1000

new ObjectList[MAX_LOADER_OBJECTS] = { INVALID_OBJECT_ID, ... };

stock AddObject(objectid, Float:ox, Float:oy, Float:oz, Float:rx, Float:ry, Float:rz)
{
    for(new i = 0; i < MAX_LOADER_OBJECTS; i++)
    {
        if(ObjectList[i] == INVALID_OBJECT_ID) ObjectList[i] = CreateObject(objectid, ox, oy, oz, rx, ry, rz);
        return ObjectList[i];
    }
    return INVALID_OBJECT_ID;
}

stock RemoveObject(indexid)
{
    if(ObjectList[indexid] != INVALID_OBJECT_ID)
    {
        DestroyObject(ObjectList[indexid]);
        ObjectList[indexid] = INVALID_OBJECT_ID;
        return 1;
    }
    return 0;
}

forward RemoveAllObjects();
public RemoveAllObjects()
{
    new RemovedObjects;
    for(new i = 0; i < MAX_LOADER_OBJECTS; i++)
    {
        if(ObjectList[i] != INVALID_OBJECT_ID)
        {
            DestroyObject(ObjectList[i]);
            ObjectList[i] = INVALID_OBJECT_ID;
            RemovedObjects++;
        }
    }
    return RemovedObjects;
}
To remove all objects on a timer

pawn Код:
SetTimer("RemoveAllObjects", 300000, false);



Re: help with DestroyObject - iJumbo - 26.04.2013

Yes i know my code is bad..

but just for make him understand what the script do...

You know..


Re: help with DestroyObject - Pottus - 26.04.2013

Quote:
Originally Posted by ******
Посмотреть сообщение
That code never actually assigns the objects. Did you test it before posting?
Thanks for pointing that out... updated it (can't believe I managed to fuck that up)