Mass DestroyObject() ?
#1

How can I make it so when I unload the FS all the objects created by it get destroyed? Is it possible to store every object's ID on it's creating with a loop or something? I'm using this filterscript https://sampforum.blast.hk/showthread.php?tid=187252 for events and such, and I'm wondering how I could destroy those objects when the filterscript is unloaded :/

Thanks.
Reply
#2

pawn Код:
new objects[howevermanyobjects];
public OnFilterScriptInit()
{
    new idx;
    objects[idx]=CreateObject(...),idx++;
    //repeat;
}

public OnFilterScriptExit()
{
    for(new idx; idx<sizeof objects; idx++)DestroyObject(objects[idx]);
Reply
#3

I know that, but there's ~220 objects, isn't there and easier way?
Reply
#4

Ctrl+H
Reply
#5

I use this on my filterscript
pawn Код:
for(new i; i < MAX_OBJECTS; i++)
    {
        DestroyObject(i);
    }
Btw, you can check my FS once XD
Reply
#6

Quote:
Originally Posted by IceMeteor
Посмотреть сообщение
I use this on my filterscript
pawn Код:
for(new i; i < MAX_OBJECTS; i++)
    {
        DestroyObject(i);
    }
Btw, you can check my FS once XD
Yeah, but that would destroy my objects created by the gamemode as well.
Reply
#7

I guess you could do:
pawn Код:
// Top
new objStart, objEnd;

// Init
objStart = CreateObject();
/* rest of objects in between here */
objEnd = CreateObject();
Then just loop from start to end on exit.
Reply
#8

if you have all objects created at once than you should go with vince's solution, but if you have it scattered around the script then add this to the top right after the includes:
pawn Код:
new FSObject[MAX_OBJECTS] = {-1,...};
stock FSOBJ_CreateObject(modelid,Float:X,Float:Y,Float:Z,Float:rX,Float:rY,Float:rZ,Float:DrawDistance = 0.0)
{
    new i;
    for(i=0;i<MAX_OBJECTS;i++)
    {
        if(FSObject[i] == -1)break;
    }
    return FSObject[i] = CreateObject(modelid,X,Y,Z,rX,rY,rZ,DrawDistance);
}
#if defined _ALS_CreateObject
    #undef CreateObject
#else
    #define _ALS_CreateObject
#endif
#define CreateObject FSOBJ_CreateObject

stock FSOBJ_DestroyObject(objectid)
{
    for(new i=0;i<MAX_OBJECTS;i++)
    {
        if(FSObject[i] == objectid)
        {
            FSObject[i] = -1;
            break;
        }
    }
    return DestroyObject(objectid);
}
#if defined _ALS_DestroyObject
    #undef DestroyObject
#else
    #define _ALS_DestroyObject
#endif
#define DestroyObject FSOBJ_DestroyObject

stock DestroyAllFSObjects()
{
    for(new i=0;i<MAX_OBJECTS;i++)
    {
        if(FSObject[i] !=-1)
        {
            DestroyObject(FSObject[i]);
            FSObject[i] = -1;
        }
    }
    return 1;
}
and use DestroyAllFSObjects() to destroy all objects Created in the filterscript
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)