-- nameinarea.lua -- Scripted by perelect. 23.07.2015. -- Detects the distance between entities and the events are only triggered by a selected entity name that comes within range. -- A learning script by perelect local DetectionRange local Entity_Distance function nameinarea_init(e) DetectionRange = 300 -- Adjust this number to change the range. end function nameinarea_main(e) for a = 1,1999 do if g_Entity[a] ~= nil then Entity_Distance = EntityDistance(e,a) if Entity_Distance < DetectionRange then if weapon_name[a] == "BlowMeUp" then -- BlowMeUp is the unique name of the entity/s that activates the events. -- Events ... You can add whatever events you like SetEntityHealth(e,0) -- this triggers an explosion from the entity with this script, if set to Explodable - You can trigger from either or both SetEntityHealth(a,0) -- this triggers an explosion from the entity that comes within range, if set to Explodable - You can trigger from either or both -- End of Events... end --PromptLocal(a,"Dist "..math.ceil(Entity_Distance)) -- 4Testing end end end end function EntityDistance(b,v) local disx = g_Entity[b]['x'] - g_Entity[v]['x'] local disz = g_Entity[b]['z'] - g_Entity[v]['z'] local disy = g_Entity[b]['y'] - g_Entity[v]['y'] return math.sqrt(math.abs(disx*disx)+math.abs(disy*disy)+math.abs(disz*disz)) end -- Free to use in commercial or non-commercial GameGuru games.