help with DestroyObject
#3

@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);
Reply


Messages In This Thread
help with DestroyObject - by dash5487 - 25.04.2013, 23:23
Re: help with DestroyObject - by iJumbo - 25.04.2013, 23:48
Re: help with DestroyObject - by Pottus - 25.04.2013, 23:55
Re: help with DestroyObject - by iJumbo - 26.04.2013, 00:10
Re: help with DestroyObject - by Pottus - 26.04.2013, 01:02

Forum Jump:


Users browsing this thread: 1 Guest(s)