Create and Destroy Dynamic(Player)Objects
#1

Hi guys

I have Roleplay server and for Winter I'm think to add snow objects.But I'm think to do that players can disable and enable snow objects.I have 500 snow objects,so my question is:Is it possible to do,and how?
I need to create 500 variable for all player?I hope no.

Quote:

native STREAMER_TAG_OBJECT CreateDynamicObject(modelid, Float, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid = -1, interiorid = -1, playerid = -1, Floattreamdistance = STREAMER_OBJECT_SD, Float:drawdistance = STREAMER_OBJECT_DD, STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1, priority = 0);

I will use parametar playerid from CreateDynamicObject to create objects for player which is enable snow objects.But I don't know how to disable(destroy) objects when players want it(and on disconnect)

I need to use DestroyDynamicObject,but I need to know all object id's.But it's 500 variable per player,i don't think that it's smart..( 500 * 250 = 125000 )

What is best to do in my case? Thanks
Reply
#2

Thank you very much for your answer.

I did it successfully.It works as I wanted..
I just have question about destroy object,is there any better way to destroy all playerobject then for loop through the whole objects.(I have many objects,so it's very big loop with many checks). (~30,000 objects...)

My code

Код:
DestroySnowObject(playerid)
{
    new data;
    for(new i; i < Streamer_GetUpperBound(STREAMER_TYPE_OBJECT); ++i) //for loop for all objects
    {
        if(!IsValidDynamicObject(i)) continue;
        Streamer_GetArrayData(STREAMER_TYPE_OBJECT, i, E_STREAMER_PLAYER_ID, data);
        if(data == playerid) 
        {
            DestroyDynamicObject(i);
        }
    }

    return 0;
}
If not.It's okay,it works.
Sorry for my English..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)