I made this function...
[lua]
hook.Add("Think", "Test", function()
for k,v in pairs(ents.FindInSphere( Vector(-2301.836914, -50.902897, -131.968750), 42)) do
if v and v:IsValid() and v:IsPlayer() then
v:ChatPrint("Test")
end
end
end)
[/lua]
Now, whenever you go within the area I set you get spammed. Well, v:ChatPrint keeps getting ran, nothing is stopping it.
How do I code it so something stops v:ChatPrint and only makes it run once?
If thats not possible can it be set to run every 15 seconds?
[lua]
hook.Add("Think", "Test", function()
if not( NextTime ) then NextTime = CurTime() end
if( NextTime < CurTime() ) then
NextTime = CurTime() + 15
for k,v in pairs(ents.FindInSphere( Vector(-2301.836914, -50.902897, -131.968750), 42)) do
if v and v:IsValid() and v:IsPlayer() then
v:ChatPrint("Test")
end
end
end
end)
[/lua]
Sorry, you need to Log In to post a reply to this thread.