This is how to do it:
PHP Code:
replaceModels()
{
level.saved_origin = [];
entitytypes = getentarray();
for( i = 0; i < entitytypes.size; i++ )
{
if( isdefined( entitytypes[i].script_gameobjectname ) )
{
gameobjectnames = strtok( entitytypes[i].script_gameobjectname, " " );
for( k = 0; k < gameobjectnames.size; k++ )
{
if( gameobjectnames[k] == "bombzone" )
{
if( entitytypes[i].classname == "script_model" )
{
level.saved_origin[level.saved_origin.size] = entitytypes[i].origin;
entitytypes[i] delete();
}
}
}
}
}
for( i=0; i < level.saved_origin.size; i++ )
{
replace = spawn( "script_model", level.saved_origin[i] );
replace setModel( "xmodel/vehicle_halftrack_rockets_snow_static" );
}
entitytypes = getentarray();
for( i = 0; i < entitytypes.size; i++ )
{
if( isdefined( entitytypes[i].script_gameobjectname ) )
{
gameobjectnames = strtok( entitytypes[i].script_gameobjectname, " " );
for( k = 0; k < gameobjectnames.size; k++ )
{
if( gameobjectnames[k] == "bombzone" )
{
if( entitytypes[i].classname == "script_brushmodel" )
{
entitytypes[i] delete();
}
}
}
}
}
}
You see the method at the foot of the function - it searches for all entities with the script_objectivename of "bombzone". Then it searches for all script_brushmodels within those entities. Then it deletes them. Simple!
Narrowing down your search enables you to target the clips in a certain area. Otherwise, you would end up deleting all the clips on the map. And that's no good.