trigger_hurt help

hey,
i have a prop hunt server i would like to add trigger_hurt or something to stop some props hiding in some glitches in some maps. i dont want to edit people’s maps without permission theres a good addon called “vermilion server management 2”. it has zones which works great but its too beefy with all the admin stuff when i use ulx. so is there something like it out there like an addon or how would i go about coding something like this.

thanks for any help

ents.FindInBox

Don’t know why LUModders answer got downvoted, but you can do it this way:



local forbiddenPositions = {
Vector(200, 200, 200),
Vector(400, 400, 400),
}

timer.Create("checkTimer", 0.6, 0, function()  -- check every 600ms
    for _, i in pairs(forbiddenPositions)
        local ents = ents.FindInSphere(i, 600) -- 600 is radius to check
        for _, v in pairs(ents) do
            if (v:IsPlayer()) then v:SetHealth(v:Health()-10) end
        end
    end
 end)


However I didn’t check the code, so can have syntax errors etc.
Just paste it in a new file in lua/autorun/server

He probably wants an even simpler solution, that he has to fly to the coordinates, and make an box from 1 corner to the other.

Probably because it’s bad to run ents.FindIn* functions continuously, they’re quite slow. Better way would be to make proper trigger-like entity using

ENTITY/Touch.

I think it’s already really simple, he just has to fly to the pos, type getpos in console, and paste the coordinates into the table.

Yep, I also thought about this, but I guess if he has only like 4 - 8 Coordinates it shouldn’t be really a problem (especially if run every x ms).

[lua]
AddCSLuaFile()
DEFINE_BASECLASS( “base_anim” )

ENT.PrintName = “”
ENT.Author = “”
ENT.Contact = “”
ENT.Purpose = “”
ENT.Instructions = “”

ENT.Spawnable = false
ENT.AdminSpawnable = false

ENT.Enabled = true

if CLIENT then
ENT.DebugMat = Material(“models/wireframe”)
end

function ENT:Initialize()

DbgPrint("Initialize")

if CLIENT then 
	hook.Add("PostDrawOpaqueRenderables", self, self.DrawDebugBox)
end

end

function ENT:AcceptInput(name, activator, caller, data)

DbgPrint("Received Input ("..tostring(self).."): "..name)

if name == "Enable" then
	print("Enabled trigger")
	self.Enabled = true
elseif name == "Disable" then
	print("Disabled trigger")
	self.Enabled = false
end

return true

end

function ENT:SetEnabled(state)
self.Enabled = state
end

function ENT:OnRemove()
if CLIENT then
hook.Remove(“PostDrawOpaqueRenderables”, self)
end
end

function ENT:Filter(ent)
return true – Always trigger
end

– Call this after creating the entity.
function ENT:Replace(trigger)

self:SetName(trigger:GetName())
	
local mins, maxs = trigger:GetModelBounds()
local pos = trigger:GetPos()
local ang = trigger:GetAngles()

trigger:Remove()	
	
local w = (maxs.x - mins.x)
local l = (maxs.y - mins.y)
local h = (maxs.z - mins.z)

mins = Vector(0 - (w / 2), 0 - (l / 2), 0 - (h / 2))
maxs = Vector(w / 2, l / 2, h / 2)

return self:Init(pos, ang, mins, maxs)

end

– Call this after creating the entity.
function ENT:Init(pos, ang, mins, maxs)

DbgPrint("Creating Trigger at " .. tostring(pos) .. "
Mins: "..tostring(mins) .. "
Maxs: " .. tostring(maxs))
		
self:DrawShadow(false)
self:SetSolid(SOLID_BBOX)
self:SetCollisionGroup(COLLISION_GROUP_WORLD)
self:SetMoveType(0)
self:SetTrigger(true)
self:Spawn()
self:SetCollisionBounds(mins, maxs)
self:SetPos(pos)
self:SetAngles(ang)
self:SetNoDraw(true)

end

function ENT:SetupDataTables()

end

function ENT:Touch( ent )
if IsValid(ent) and ent:IsPlayer() and self.Enabled == true then
if self:Filter(ent) then
self:Trigger(ent)
end
end
end

function ENT:Trigger(ent)
return false – Override me.
end

function ENT:EndTouch( ent )
end

function ENT:Draw()
self:DrawModel()
end

function ENT:DrawDebugBox()
if GetConVarNumber(“coop_drawtriggers”) >= 1 then

	local mins = self:OBBMins()
	local maxs = self:OBBMaxs()
	local pos = self:GetPos() 
	local ang = self:GetAngles()
	
	render.SuppressEngineLighting( true )
	render.SetColorModulation( 1, 1, 1 )
	render.SetMaterial(self.DebugMat)
	render.SetBlend(1)
	render.DrawBox(pos, ang, mins, maxs, Color(255, 255, 255, 155))
	render.SuppressEngineLighting( false )
end

end

function ENT:TriggerOutputs()
if self.Outputs then
for _, out in pairs(self.Outputs) do
local entname = out[1]
local cmd = out[2]
local delay = out[3] or 0
local param = out[4] or “”

		local targetents = ents.FindByName(entname) or {}
		for k,v in pairs(targetents) do
			v:Fire(cmd, param, delay)
		end
	end
end

end
[/lua]

You could do by that code just

[lua]
local trigger = ents.Create(“trigger_name”)
trigger:Init(position, angles, min_size, max_size)
trigger.Trigger = function(self, ent)
print("Triggered by: " … tostring(ent))
end
[/lua]

You should consider this instead of FindInBox

thank you so much for the help guys how do i thank people for their posts? and how would i define the maps for each different triggers?