"Hook" for crash?

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?

If you’ve seen Anti-Crash scripts, why Don’t you open them up and look into them?

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]

Because all I’ve seen are private or paid. He’s asking a fair question.

How would I use that?

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.

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.

It’s a pretty bad solution as there are many reasons why a server may stop responding temporarily without necessarily crashing…

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.

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.

I think it’s to auto-reconnect

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.

hook.Add(“OnCrash”,“Don’t Crash”,function()
return false

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 : http://darkstorm.site.nfoservers.com/server/lua/autorun/anticrash.lua - shit code but I’m sure someone will rewrite it and do a better job of it.

Gonna sell this on SF for 10$ each, I hope the admins on SF will accept it.