SA-MP Forums Archive
Removing Objects which are in a specific virtual world - 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: Removing Objects which are in a specific virtual world (/showthread.php?tid=536860)



Removing Objects which are in a specific virtual world - XxBaDxBoYxX - 12.09.2014

Hello.
If I have 500 object, 250 in virtual world ID 0 and 250 in Virtual world ID 1
Is it possible to remove objects which are in virtual world ID 1 without having to define them all and use normal way ?

I've tried this code
Код:
	for(new i; i<MAX_OBJECTS; i++)
	{
		if(IsValidObject(i)) DestroyObject(i);
	}
but that simply removes all objects. :/


Re: Removing Objects which are in a specific virtual world - CutX - 12.09.2014

//EDIT: i was wrong, read my next post
Quote:
Originally Posted by XxBaDxBoYxX
Посмотреть сообщение
without having to define them all
no, cuz when removing them, you need to check if theyre in that specific virtual world.
Only possible if you can identify the vw-id by object id

like...
pawn Код:
object[0][0] = createObject(.....
object[0][1] = 4;//virtual world
currently, there is no native function for something like this.
But you could write your own if you really need it
or just hook your create(dynamic)object & make it save the virtual world somewhere
once an object is being created so that it's available for later use.


Re: Removing Objects which are in a specific virtual world - Pottus - 12.09.2014

The streamer plugin handles this of course.


Re: Removing Objects which are in a specific virtual world - AroseKhanNiazi - 12.09.2014

ye as pottus said by that first make the objects in world you want add them there again and remove the objects that are already there


Re: Removing Objects which are in a specific virtual world - CutX - 12.09.2014

Quote:
Originally Posted by Pottus
Посмотреть сообщение
The streamer plugin handles this of course.
true! i was wrong, so i looked more into it.

here's an example on how some1 could get hold of the virtual world id by
just using the object id.

pawn Код:
new ob = CreateDynamicObject(1804, 0, 0, 0, 0, 0, 0, 3);
    new x = Streamer_GetIntData(STREAMER_TYPE_OBJECT, ob, E_STREAMER_WORLD_ID);
    printf("\nVW: %d",x);
it'll print
VW: 3

so by using the streamer plugin:
pawn Код:
//will destroy every valid object in world 1
    for(new i; i<MAX_OBJECTS; i++)
    {
        if(IsValidDynamicObject(i))
            if(Streamer_GetIntData(STREAMER_TYPE_OBJECT, i, E_STREAMER_WORLD_ID) == 1)// 1 is our virtual world id
                DestroyDynamicObject(i);
    }



Re: Removing Objects which are in a specific virtual world - XxBaDxBoYxX - 12.09.2014

Thanks but If I would define them anyway, I would use the define > remove way.
Thanks anyway.


Re: Removing Objects which are in a specific virtual world - CutX - 12.09.2014

Quote:
Originally Posted by XxBaDxBoYxX
Посмотреть сообщение
Thanks but If I would define them anyway, I would use the define > remove way.
Thanks anyway.
you don't have to define them at all.
just use the streamer plugin and do it like in my last post, the one with the for loop at the end
that'll do the trick without defining anything.

first, we check if i is a valid object and then we check if its in a world, specified by us.
then we simply destroy it