• Timers with out players.
    16 replies, posted
Is there a way to make a timer (or somthing acting as a timer) that starts running before a player connects?.
Define "before". On server startup? Just before he spawns?
[QUOTE=_nonSENSE;23341050]Define "before". On server startup? Just before he spawns?[/QUOTE] He means the fact that a player need to join before the think hook gets called ( Therefore breaking timers ) [editline]12:18AM[/editline] There's no real easy way to do this, besides from spawning a bot and then kicking it in an InitPostEntity hook. Unreliable method.
Mabey Garry should make a new hook like think that runs even when players are no connected. like ever 0.01 seconds instead of every frame or something. Also i've tried spawning a bot with lua, RunConsoleCommand and game.Command or any other related functions don't seem to run the command.
One thing you could do is checking on the first time PlayerInitialSpawn is called if any of the "timers" you've setup should now have expired. If they have then emulate the effects they should have produced. If they haven't set them up properly accounting the time that has elapsed since the server started. The best way to do that would be a new kind of timer library.. I guess. The question is, why do you need timers to run at all when there is no player present? If it is something that should affect the players then surely you can emulate the passing of time once a player joins in the way I have described. Don't try to force the game into doing ineffective things.
What i'm doing is sending a signal to a few other servers on the dedicated every 5 seconds. If these signals stop the other servers know that the server has crashed, But when the signals start again they know the servers back up and running. Thus my website and all my servers know whats going on. If a server is to crash or boot it will alert all the players that of that. When a player is on the server then it works. Ofc the other servers will only think that the server has actualy started working once sombody joins it, This being why i need a timer to run when players are not (or have not been) present.
[url]http://wiki.garrysmod.com/?title=Gamemode.Initialize[/url] This might be what you're looking for.
[QUOTE=??????;23346815][url]http://wiki.garrysmod.com/?title=Gamemode.Initialize[/url] This might be what you're looking for.[/QUOTE] No not really though. (Mabey you should read the thread a bit more?)
why not try to do in your postEntityHook hook.Call("Think") or w/e the syntax is!
The problem is Think is never called before a player joins. I think its because Think is called on tick, and there isn't a tick with out a player. I'm most likely 100% wrong about that. :( Anyway this isue is not realy an issue for me now mainly because i've moved on.
[QUOTE=goluch;23351562]No not really though. (Mabey you should read the thread a bit more?)[/QUOTE] Are you sure? This gets called when the server is being setup, so you could immediately send a net message to notify the server has gone up.
[QUOTE=Crazy Quebec;23360879]Are you sure? This gets called when the server is being setup, so you could immediately send a net message to notify the server has gone up.[/QUOTE] What if it doesn't send it? That could mean that the server is still up or has crashed and hasn't restarted.
[lua]timer.Simple(0 , function() LOADED = true end ) hook.Add("InitPostEntity" , "Load" , function() if not LOADED then game.ConsoleCommand("bot\n") timer.Create("Derp" , 5 , 1 , function() hook.Remove("InitPostEntity" , "Load") player.GetByID(1):Kick("No longer required") end ) LOADED = true end end ) [/lua]
[QUOTE=Flapadar;23362151][lua]timer.Simple(0 , function() LOADED = true end ) hook.Add("InitPostEntity" , "Load" , function() if not LOADED then game.ConsoleCommand("bot\n") timer.Create("Derp" , 5 , 1 , function() hook.Remove("InitPostEntity" , "Loadit") player.GetByID(1):Kick("No longer required") end ) LOADED = true end end ) [/lua][/QUOTE] didn't you mean Load and not Loadit?
Yeah.
Timers use Think.
[QUOTE=amcwatters;23362818]Timers use Think.[/QUOTE] That's the point. Since a bot was added the server will start thinking run the timers. (That's the theory anyway. I don't know that from experience.)
Sorry, you need to Log In to post a reply to this thread.