Getting an entity to destroy itself

Hi guys, need a little help with something…how would I make it so that say I spawn a money printer but it can only spawn at a certain point in the map and when you go a certain distance away from that place it will blow up. Also a message will appear saying “Your not in the correct area to spawn this” when you try to spawn it outside the set point of the map…been toying with the lua for it for ages…can’t seem to get the lua theory down.

To check ent position each frame

ENTITY/Think
Get Entity position

Entity:GetPos
Entity Distance from a vector

Vector:Distance
Remove the entity

Entity:Remove
Send player message

Player:ChatPrint

hook.Add( “Think”, function()
for _, ent in pairs( ents.GetAll() ) do
local x = …
local y = …
local z = …
local distance = 5 – whatever

    if ( ent:GetPos():Distance( x, y, z ) == distance ) then
          ent:GetOwner():ChatPrint( "You can't spawn entities in this area!" )
          ent:Remove()
    end
    
    
end

end

would that be done client side or server side

Serverside

[editline]18th July 2015[/editline]

And replace … with a certain coordinate

Thanks for the help man, I assume I put this code inside the actual entity code also does this make it so when you actually leave a certain point it destroys ? or is this to make it so the area cannot have things spawned inside it

Well, actually that code will remove every entity out of wherever you put the coords (Including players)
You should check my links, and if you really can’t do something like this or “Toy in lua” (For ages? What? Lua it’s pretty easy to understand with all these tutorials on wiki) i recommend you to hire someone on scriptfodder

Oh shit yeah…