native Streamer_GetIntData(type, {Text3D,_}:id, data);
native Streamer_CountItems(type, serverwide = 1);
native Streamer_DestroyAllItems(type, serverwide = 1);
// Looping through all of the objects on the server.
for(new i = 0; i < Streamer_CountItems(STREAMER_TYPE_OBJECT, 1); i++)
{
// Getting the virtual world of the object.
new virtual_world = Streamer_GetIntData(STREAMER_TYPE_OBJECT, i, E_STREAMER_WORLD_ID);
// For example let's say we want to destroy all the objects in virtual world 777.
if(virtual_world == 777) { DestroyDynamicObject(i); }
}
*** Streamer_GetIntData: Invalid data specified
for(new i = 0; i < Streamer_CountItems(STREAMER_TYPE_OBJECT, 1); i++)
{
new World = Streamer_GetIntData(STREAMER_TYPE_OBJECT, i, E_STREAMER_WORLD_ID);
if(World == WORLD_CSDM) DestroyDynamicObject(i);
}
for(new i = 0; i < CountDynamicObjects(); i++)
{
new World = Streamer_GetIntData(STREAMER_TYPE_OBJECT, i, E_STREAMER_WORLD_ID);
if(World == WORLD_CSDM) DestroyDynamicObject(i);
}
|
Also, the server freezes for 5 seconds when using that snippet |
for(new i = 0; i < CountDynamicObjects(); i++)
{
if(!IsValidDynamicObject(i)) continue;
if(Streamer_GetIntData(STREAMER_TYPE_OBJECT, i, E_STREAMER_WORLD_ID) != WORLD_CSDM) continue;
DestroyDynamicObject(i);
}
public OnGameModeInit()
{
CreateDynamicObject(3534, 2105.08276, 1003.17114, 45.41970, 0.0, 0.0, 0.0, 0, 0, -1); //objectid: 1
CreateDynamicObject(3534, 2110.11450, 1003.30292, 45.41975, 0.0, 0.0, 0.0, 0, 0, -1); //objectid: 2
CreateDynamicObject(3534, 2109.27148, 1001.49146, 45.41970, 0.0, 0.0, 0.0, 1, 0, -1); //remove this || objectid: 3
CreateDynamicObject(3534, 2106.31641, 1001.41577, 45.41970, 0.0, 0.0, 0.0, 0, 0, -1); //objectid: 4
CreateDynamicObject(3534, 2109.27148, 1004.59882, 45.41970, 0.0, 0.0, 0.0, 1, 0, -1); //remove this || objectid: 5
CreateDynamicObject(3534, 2106.31641, 1004.71191, 45.41970, 0.0, 0.0, 0.0, 0, 0, -1); //objectid: 6
return SetTimer("deleteMe", 1000, 0);
}
forward deleteMe();
public deleteMe()
{
for(new objectid = 1, j = Streamer_CountItems(STREAMER_TYPE_OBJECT, 1); objectid != j; objectid++)
{
if(!IsValidDynamicObject(objectid) || Streamer_GetIntData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_WORLD_ID) != 1)
{
continue;
}
printf("DestroyDynamicObject(%d)", objectid);
DestroyDynamicObject(objectid);
}
return 1;
}