Ulysses

General => Developers Corner => Topic started by: captain1342 on March 15, 2017, 07:48:30 AM

Title: 2 Questions: ChatConnector , Check if the Server Crashed
Post by: captain1342 on March 15, 2017, 07:48:30 AM
So i have a new project I am working on and maybe you know how I should start.

First: I would need for the addon an Build-In chat system which is does not require a server connection and now just the questuion is, What should I use as Chat server?
I thought about some possibilities but what would you prefer?
My Ideas:
Quote
IRC
Discord
It must be aviable clientside ( the script will just run client side )

Second: Is there an easy way to detect a Server crash from the client?

I thought about something complicated using timer's and the net lib but I think there is a simpler way I just don't know yet.

Thanks for reading,

~MG
 PS: Suggestions are welcomed ;)
Title: Re: 2 Questions: ChatConnector , Check if the Server Crashed
Post by: iViscosity on March 15, 2017, 08:37:52 AM
I'm confused about what you're asking in your first question... I know something like Discord Chat Relay (https://scriptfodder.com/scripts/view/3277) exists (costs $3.50, though), if that's sort of what you're asking.

As for your second question, there is another thing: Server Crash Menu & Auto Reconnection (https://scriptfodder.com/scripts/view/814/server-crash-menu-auto-reconnection), however that costs $3.99. If you don't want to pay (I don't blame you) there is likely a free version of some of those somewhere, but if you'd like to make it yourself (at least for the crashing, not sure about the Discord/IRC), you could add a Think (https://wiki.garrysmod.com/page/GM/Think) hook (or a timer that ticks every couple seconds) that checks everyone's ping and sees if all of them are the same. Pings constantly fluctuate even on a minor scale (1-2 ms) so if you check every person in a "for" loop for their Player:Ping() (https://wiki.garrysmod.com/page/Player/Ping) and they are all the same, the server most likely crashed. It's best to add another Think (https://wiki.garrysmod.com/page/GM/Think) hook to check for a crash recovery (or a false-alarm) by storing the ping everyone had when the server crashed (in the first hook) then comparing in the second. If they're different then, it will continue as normal.