SA-MP Forums Archive
destroy objects with the same id ? - 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: destroy objects with the same id ? (/showthread.php?tid=456880)



destroy objects with the same id ? - omidi - 07.08.2013

hi
etc i want destory all objects were created and all of them were id 1225

then how to destory all those objects with the same id ?

Код:
	for(new i; i<MAX_OBJECTS; i++)
	{
	     if(IsValidObject(i) && i==1225)
	          DestroyDynamicObject(i);
	}



Re: destroy objects with the same id ? - Macluawn - 07.08.2013

Dont confuse model id with object id.


Re: destroy objects with the same id ? - Admigo - 07.08.2013

What you can do is create your own CreateObjectEx to detect the model ids.
pawn Код:
new ModelID[MAX_OBJECTS];//top of script
new ObjectID=0;//top of script

stock CreateObjectEx(modelid,Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz)
{
        ObjectID++;
    CreateObject(modelid,x,y,z,rx,ry,rz);
        ModelID[ObjectID]=modelid;
}

//place this where you want it
for(new i; i<MAX_OBJECTS; i++)
{
    if(IsValidObject(i) && ModelID[i]==1225)
    DestroyDynamicObject(i);
}
I didnt tested the code so tell me if you have issues.