Think doesn't run when server is empty - need alternative.

I need a ‘map scan’ to run upon server start, even if there is no one in the server.
I considered using a while true do loop, but that would lock up the server and prevent players from joining.

I’m considering using Lua Lanes to make an alternative thread with a sleep interval call the main function, but I don’t think you can cross-call and moving the code into another thread is not an option.

Halp D:

Edit: Timers and schedule won’t work, as they use the Think hook :frowning:

Do timers work? or maybe the tick hook, not sure if it does but worth a try.

Timers won’t work either.

Forgot to mention that…
Thanks for the suggestion, though.

If you are really desperate, do what Hardy did, add a bot.

Timers won’t work because they are controlled by think hook :slight_smile:
Edit: oops, good job reading again. Mentioned in op…

Myself I had a problem where I wanted to run a certain thing after server had started. I ended up using SourceMod and pawn, it got the job done.

use bots?
Spawn one in InitPostEntity with game.ConsoleCommand(“bot”) and kick it when you’re done with your scan.



I was under the impression that bots didn’t count in the decision to run Think or not…
I’ll test it tomorrow.
If it works, thanks!
If not, meh… thanks!

works fine, I’ve used it several times.

I had this problem when coding the TYE servers, they needed to listen for network data every tick which was a problem when nobody was in the server. However, I discovered that once a player has been in the server, the Tick hook (not sure about Think) always runs from that point onwards - even if the player leaves again or the server map changes. It only stops getting called again if the server does a full restart. Bots do trigger it off. So you could make a bot in Initialize hook and kick it in the first Tick hook, and use Tick for your stuff.