#include <amxmodx> 
#include <engine>
#include <fakemeta>

#define REMOVE_TIME 20.0 

public plugin_init( )
{ 
	register_forward( FM_SetModel, "FwdSetModel", 1 ); 
	
	new bz = FindBuyZones( )
	new Float:absmin[3] = {-18191.0, -18191.0, -18191.0}
	new Float:absmax[3] = {18191.0, 18191.0, 18191.0}
	if ( !bz )
	{
		new buyzone = create_entity("func_buyzone") // create buyzone entity and set it max size of map
		DispatchSpawn(buyzone)
		entity_set_size(buyzone, absmin, absmax)
	}
	else
	{
		entity_set_size(bz, absmin, absmax)
	}
} 

public FwdSetModel( iEntity ) 
{ 
	if( !pev_valid( iEntity ) ) 
		return; 
     
	static const szWeaponbox[] = "weaponbox"; 
	static szClassname[ 10 ]; // weaponbox 
	pev( iEntity, pev_classname, szClassname, charsmax( szClassname ) ); 
     
	if( equal( szClassname, szWeaponbox ) ) 
		set_pev( iEntity, pev_nextthink, get_gametime( ) + REMOVE_TIME ); 
}  


FindBuyZones( ) 
{
	new iEntity = -1;
    
	while( ( iEntity = find_ent_by_class( iEntity, "func_buyzone" ) ) > 0 )
	{
		return iEntity
	}
	return 0
}
