• "Hook" for crash?
    16 replies, posted
Hello FP, I've seen some "Anti-Crash" Scripts, and I wanted to know how they notice if the server crashes? Is there a special hook or so?
[QUOTE=whitestar;48381818]Hello FP, I've seen some "Anti-Crash" Scripts, and I wanted to know how they notice if the server crashes? Is there a special hook or so?[/QUOTE] If you've seen Anti-Crash scripts, why Don't you open them up and look into them?
[QUOTE=tzahush;48381958]If you've seen Anti-Crash scripts, why Don't you open them up and look into them?[/QUOTE] I've only seen them on scriptfodder, not the Lua files themself, and therefore I want to code one by myself, since I dont have the money.
The server and client keep sending net messages back and forth to each other every 5 seconds or so. If there's no response from the server back to the client, then a crash is assumed. [editline]5th August 2015[/editline] [QUOTE=tzahush;48381958]If you've seen Anti-Crash scripts, why Don't you open them up and look into them?[/QUOTE] Because all I've seen are private or paid. He's asking a fair question.
[QUOTE=code_gs;48382007]The server and client keep sending net messages back and forth to each other every 5 seconds or so. If there's no response from the server back to the client, then a crash is assumed. [editline]5th August 2015[/editline] Because all I've seen are private or paid. He's asking a fair question.[/QUOTE] [url]https://garrysmods.org/download/2146/anticrashzip[/url]
[QUOTE=code_gs;48382007]-snip-[/QUOTE] How would I use that?
[QUOTE=whitestar;48382040]How would I use that?[/QUOTE] you could maybe send a net message every - 3 seconds, if the guy didn't get it after lets say after 5 seconds(just making sure), then server is down.
[QUOTE=tzahush;48382058]you could maybe send a net message every - 3 seconds, if the guy didn't get it after lets say after 5 seconds(just making sure), then server is down.[/QUOTE] Check in the send interval + 1; so if a message is sent every 3 seconds, assume a crash if the client does not get it in 7 seconds. This compensates for net lag and eaten messages.
[QUOTE=code_gs;48382258]Check in the send interval + 1; so if a message is sent every 3 seconds, assume a crash if the client does not get it in 7 seconds. This compensates for net lag and eaten messages.[/QUOTE] It's a pretty bad solution as there are many reasons why a server may stop responding temporarily without necessarily crashing..
[QUOTE=Hoffa1337;48388796]It's a pretty bad solution as there are many reasons why a server may stop responding temporarily without necessarily crashing..[/QUOTE] Yes, but there's not a better solution. As long as you include a clientside timeout timer that still constantly checks for the response, you'll be fine.
[QUOTE=code_gs;48389259]Yes, but there's not a better solution. As long as you include a clientside timeout timer that still constantly checks for the response, you'll be fine.[/QUOTE] It kinda depends what the purpose of the crash "hook" is ? I mean if it's solely to detect if the server went down at any point writing a file on succesful shutdown and reading said file on launch is the way to go.
[QUOTE=Hoffa1337;48389673]It kinda depends what the purpose of the crash "hook" is ? I mean if it's solely to detect if the server went down at any point writing a file on succesful shutdown and reading said file on launch is the way to go.[/QUOTE] I think it's to auto-reconnect
[QUOTE=code_gs;48390026]I think it's to auto-reconnect[/QUOTE] then your approach makes more sense.
The "Anti Crash" you're referring to is a script that shows a message when the server stops sending net messages to you. It has a misleading name, it doesn't actually prevent any crashes.
[lua] hook.Add("OnCrash","Don't Crash",function() return false end) [/lua]
[QUOTE=freakyy;48390170]The "Anti Crash" you're referring to is a script that shows a message when the server stops sending net messages to you. It has a misleading name, it doesn't actually prevent any crashes.[/QUOTE] It also reconnects players automatically so once your server monitor/reboot script does its job, you keep most of your players (rather than them timing out and disconnecting), which is the most annoying thing about srcds dying really. I found a fixed version of the script I wrote a few years back : [url]http://darkstorm.site.nfoservers.com/server/lua/autorun/anticrash.lua[/url] - shit code but I'm sure someone will rewrite it and do a better job of it.
[QUOTE=gonzalolog;48390880][lua] hook.Add("OnCrash","Don't Crash",function() return false end) [/lua][/QUOTE] Gonna sell this on SF for 10$ each, I hope the admins on SF will accept it.
Sorry, you need to Log In to post a reply to this thread.