Code:
function Ohai_Trigger_Spawn_SPAWN(pUnit, Event)
pUnit:RegisterEvent("aejheiojahoeaoeaog_oh_la_la", 1500, 0)
end
function aejheiojahoeaoeaog_oh_la_la(pUnit, Event)
local BVZABZ = pUnit:GetClosestPlayer()
if BVZABZ ~= nil then
if pUnit:GetDistanceYards(BVZABZ) < 5 then
pUnit:RemoveEvents()
-- do stuff
end
end
end
RegisterUnitEvent(158801, 18, "Ohai_Trigger_Spawn_SPAWN")
Example snippet of code, full code this was taken from can be found here: http://subversion.assembla.com/svn/K...ortalGlade.lua
Basically, a on spawn function that checks for whether there are nearby players and if there are whether they are close enough to continue.