Checking if a player is within a certain zone

I have a ttt_traitor_button in my TTT map, but I only want it to be used if the traitor who presses it is inside the room. Obviously a ttt_traitor_button can be seen and used through walls, and I don’t want that to be possible in this instance.

When the player presses the floating traitor button, how could I test if the player (!activator) is inside the room and only fire the output if he is?

Trigger_multiple? Disable the traitor button when they’re not in the area I guess.

That wouldn’t work, seeing as one traitor could be inside the room enabling the traitor button, and another traitor outside the room could press the button.

You would need to do this via Lua. It would need to check for all traitors that are playing, then if they are all in the room. Use a trigger multiple to fire an lua_run that calls the script. It shouldn’t be to hard for someone who knows lua well.

I have an idea! Is it possible to give the !activator of the button a specific targetname and then enable a trigger_multiple that is filtered for that name via filter_activator_name? That way, the trigger_multiple could carry out the output of the button and nothing would happen if the traitor activated the button from outside the room.

I’ve had no luck over in the Lua section with this. They tell me it isn’t possible via Lua.

[editline]7th December 2013[/editline]

I have done the (seemingly) impossible!

I created a trigger_multiple filtered for the name traitor_1 via the filter_activator_name entity. I moved the ttt_traitor_button’s output over to the trigger_multiple instead.
I then set up the ttt_traitor_button’s output like so:

targetname traitor_1

targetname none

What’s happening here is that the trigger_multiple is constantly looking for anything named “traitor_1” within it’s volume. The ttt_traitor_button changes the name of the player who activated it to “traitor_1” for a split second, effectively activating the output ONLY when the traitor is in the room. Otherwise nothing will happen. I also was able to display a message to the player if he isn’t in the room and tries to use the button. Perfect.

Furthermore, I talked to the creator of TTT and based on our discussion he has just released an update for TTT to let mappers set the useable distance for the ttt_traitor_button.