Blocking off areas, removing certain props on TTT

I know there was a thread here, but I didn’t want to hijack it.

We’re interested in removing certain props on some maps (such as the hatchet on Rooftops), and blocking off certain areas can eventually come into use, depending. Which addons would be able to do this? Preferably not ones from Coderhire.

Code it yourself. ents.FindInSphere will get you your second one.

ents.FindInSphere wouldn’t be good. It’s very resource hungry. Just use ents.GetAll and remove the ones you don’t want. Remember, TTT cleans the map after every round / each state-change, so you’ll need to run it each round state change so unauthorized props can’t be picked up and used in-between rounds with the possibility of them being able to keep them.

I wish there was a hook for PreCleanup and PostCleanup - I’ll add that to my list of additions; server-side. Here’s a simplified tutorial on it; expand on it by reading string.lower( game.GetMapName( ) ) .txt from your server-data folder of JSON data list of props…

Unfortunately, TTT calls cleanup map each time it changes round-status. I’d recommend writing something like this:

[lua]//
//
//
hook.Add( “InitPostEntity”, “TTTPropRemover:InitPostEntity”, function( )
prop_remover:Read( );
prop_remover:Run( );
end );

//
//
//
hook.Add( “TTTBeginRound”, “TTTPropRemover:TTTBeginRound”, function( )
prop_remover:Run( );
end );

//
//
//
hook.Add( “TTTEndRound”, “TTTPropRemover:TTTEndRound”, function( )
prop_remover:Run( );
end );

//
//
//
hook.Add( “TTTPrepareRound”, “TTTPropRemover:TTTPrepareRound”, function( )
prop_remover:Run( );
end );[/lua]

where prop_remover is a new meta_table system, Run executes the function to remove the props, and Read loads the file into memory.

I created a bigger than expected tool to allow admins to walk around and prop_remover /addclass or /delclass ( where Addclass adds it to the removal list and delclass removes it from deletion list ); where you need to prop_remover /confirm to activate the working object, etc.

Here’s the Run function which should be straight-forward… Store the classes as a KEY instead of value, the value can be true or whatever. Similar to: https://dl.dropboxusercontent.com/u/26074909/tutoring/benchmarking_tips/benchmarking_hud_stuff.lua this direct access example. And it needs to be run on all 3 hooks.

If you want the full thing with management concommand, let me know on Steam: http://steamcommunity.com/id/Acecool

[lua]//
// Removing Unwanted Props in a Map TTT based- Josh ‘Acecool’ Moser
//
–[[
Removing unwanted props in a map can be beneficial for increasing speed, remove exploitable props, or whatever reason…

As a hook doesn't exist for PreCleanup and PostCleanup, we'll use -- GAMEMODE:OnCleanup is called, but not hook.Called:
Also, Cleanup Map is called on all state-changes, which may be why starting a round, etc may lag a bit. We'll need to call on all 3 to ensure
they don't touch entities during any phase. This should be changed...
	TTTBeginRound
	TTTEndRound
	TTTPrepareRound

]]

//
// Part of read READ to understand the structure
//
// Initialize each individual sub-portion to be used for instant checks to avoid searches
if ( !prop_remover.__Data.class ) then prop_remover.__Data.class = { }; end

//
//
//
function prop_remover:Run( )
if ( table.Count( prop_remover.__Data ) < 1 ) then return false; end

for k, _ent in pairs( ents.GetAll( ) ) do
	if ( !IsValid( _ent ) ) then continue; end

	// Class Detection
	local _class = _ent:GetClass( );
	if ( prop_remover.__Data.class[ _class ] ) then
		SafeRemoveEntity( _ent );
	end
end

return true;

end
[/lua]

Read function simply populates the Data table