Garrys mod server crash screen

Lately I have been practicing with derma menus and thought of something cool to make. I was thinking I could make a derma menu that would open if the server were to crash so that people could realize what happened and then reconnect. I think the best way to do this would be using a if statement. But im not sure how to do this. Would I have to check for the server latency? And if so then how would I go about doing that? Thanks for any help.

I don’t think many crash screens are made with derma since once the game’s crashed I doubt any derma things would even work- but if you want to do a check for server latency, most people from what I’ve heard just send a message from the server to the client every couple of seconds, and if the client doesn’t send a message back, then it usually means they’ve timed out.

[editline]15th July 2016[/editline]

You could also try


**EDIT: **Sorry, since I’ve never made a crash screen before I have no clue what people would use instead of derma

Sorry im so inexperienced, but do you know what else you would use to make something like that display on the screen? Im just trying to learn lua and I heard derma was a good way to learn, but if there is another way to display menus on the screen I would love to investigate.

Off the top of my mind, you could use

Player:Ping and then if it gets too high, start a timer and if at the end of that timer the ping is still really high, you could say the server crashed?

But the issue I see with that is that if a player just has a bad connection then it might cause it to happen.

A simple, but quite sloppy method, would be to make a ping/pong system from the client to the server. You could achieve this with the net library. For instance, you could set it up so that every now and then, a message is sent from the server to the client and vice versa upon the client receiving a message. This could then be used to check if the server - or the client - misses a few pings in a row then you can assume the server has crashed.

I don’t think there is a client sided way to check if you are disconnected from the server. What I did in the past was a ping pong system like josh said. Server pings the client every so often. If the client doesn’t get one of these pings in a cetain amount of time, the client will assume the server is down and display the menu.